Mercurial > piecrust2
annotate 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 |
rev | line source |
---|---|
0 | 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): | |
1
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
51 def __init__(self): |
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
52 super(StandardEnvironment, self).__init__() |
0 | 53 |