Mercurial > piecrust2
comparison piecrust/taxonomies.py @ 3:f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
- Serving works, with debug window.
- Baking works, multi-threading, with dependency handling.
- Various things not implemented yet.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 10 Aug 2014 23:43:16 -0700 |
parents | |
children | f130365568ff |
comparison
equal
deleted
inserted
replaced
2:40fa08b261b9 | 3:f485ba500df3 |
---|---|
1 from piecrust.sources.base import PageRef, PageNotFoundError | |
2 | |
3 | |
4 class Taxonomy(object): | |
5 def __init__(self, app, name, config): | |
6 self.app = app | |
7 self.name = name | |
8 self.term_name = config['term'] | |
9 self.is_multiple = config['multiple'] | |
10 self.page_ref = config['page'] | |
11 self._source_page_refs = {} | |
12 | |
13 def resolvePagePath(self, source_name): | |
14 pr = self.getPageRef(source_name) | |
15 try: | |
16 return pr.path | |
17 except PageNotFoundError: | |
18 return None | |
19 | |
20 def getPageRef(self, source_name): | |
21 if source_name in self._source_page_refs: | |
22 return self._source_page_refs[source_name] | |
23 | |
24 source = self.app.getSource(source_name) | |
25 ref_path = (source.getTaxonomyPageRef(self.name) or | |
26 '%s:%s' % (source_name, self.page_ref)) | |
27 page_ref = PageRef(self.app, ref_path) | |
28 self._source_page_refs[source_name] = page_ref | |
29 return page_ref | |
30 |