Mercurial > piecrust2
view piecrust/environment.py @ 1:aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Added `init` command.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 22 Dec 2013 08:00:24 -0800 |
parents | a212a3f2e3ee |
children | f485ba500df3 |
line wrap: on
line source
import logging from decorators import lazy_property logger = logging.getLogger(__name__) class PageRepository(object): pass class ExecutionContext(object): pass class Environment(object): def __init__(self): self.page_repository = PageRepository() self._execution_ctx = None def initialize(self, app): pass @lazy_property def pages(self): logger.debug("Loading pages...") return self._loadPages() @lazy_property def posts(self): logger.debug("Loading posts...") return self._loadPosts() @lazy_property def file_system(self): return None def get_execution_context(self, auto_create=False): if auto_create and self._execution_ctx is None: self._execution_ctx = ExecutionContext() return self._execution_ctx def _loadPages(self): raise NotImplementedError() def _loadPosts(self): raise NotImplementedError() class StandardEnvironment(Environment): def __init__(self): super(StandardEnvironment, self).__init__()