Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a212a3f2e3ee |
---|---|
1 import logging | |
2 from decorators import lazy_property | |
3 | |
4 | |
5 logger = logging.getLogger(__name__) | |
6 | |
7 | |
8 class PageRepository(object): | |
9 pass | |
10 | |
11 | |
12 class ExecutionContext(object): | |
13 pass | |
14 | |
15 | |
16 class Environment(object): | |
17 def __init__(self): | |
18 self.page_repository = PageRepository() | |
19 self._execution_ctx = None | |
20 | |
21 def initialize(self, app): | |
22 pass | |
23 | |
24 @lazy_property | |
25 def pages(self): | |
26 logger.debug("Loading pages...") | |
27 return self._loadPages() | |
28 | |
29 @lazy_property | |
30 def posts(self): | |
31 logger.debug("Loading posts...") | |
32 return self._loadPosts() | |
33 | |
34 @lazy_property | |
35 def file_system(self): | |
36 return None | |
37 | |
38 def get_execution_context(self, auto_create=False): | |
39 if auto_create and self._execution_ctx is None: | |
40 self._execution_ctx = ExecutionContext() | |
41 return self._execution_ctx | |
42 | |
43 def _loadPages(self): | |
44 raise NotImplementedError() | |
45 | |
46 def _loadPosts(self): | |
47 raise NotImplementedError() | |
48 | |
49 | |
50 class StandardEnvironment(Environment): | |
51 pass | |
52 |