Mercurial > piecrust2
diff piecrust/environment.py @ 0:a212a3f2e3ee
Initial commit.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 21 Dec 2013 14:44:02 -0800 |
parents | |
children | aaa8fb7c8918 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/piecrust/environment.py Sat Dec 21 14:44:02 2013 -0800 @@ -0,0 +1,52 @@ +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): + pass +