Mercurial > piecrust2
comparison piecrust/data/builder.py @ 83:f9f67086415c
Allow adding to the default content model instead of replacing it.
Allow dot and slash notation for data endpoints.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 01 Sep 2014 22:49:56 -0700 |
parents | cb1ed436642c |
children | a643b14a59a3 |
comparison
equal
deleted
inserted
replaced
82:ae90caf26224 | 83:f9f67086415c |
---|---|
1 import re | |
1 import time | 2 import time |
2 import logging | 3 import logging |
3 from piecrust import APP_VERSION | 4 from piecrust import APP_VERSION |
4 from piecrust.configuration import merge_dicts | 5 from piecrust.configuration import merge_dicts |
5 from piecrust.data.assetor import Assetor | 6 from piecrust.data.assetor import Assetor |
101 | 102 |
102 def _debugRenderDebugInfo(self): | 103 def _debugRenderDebugInfo(self): |
103 return "The very thing you're looking at!" | 104 return "The very thing you're looking at!" |
104 | 105 |
105 | 106 |
107 re_endpoint_sep = re.compile(r'[\/\.]') | |
108 | |
109 | |
106 def build_site_data(page): | 110 def build_site_data(page): |
107 app = page.app | 111 app = page.app |
108 data = dict(app.config.get()) | 112 data = dict(app.config.get()) |
109 for source in app.sources: | 113 for source in app.sources: |
110 endpoint_bits = source.data_endpoint.split('/') | 114 endpoint_bits = re_endpoint_sep.split(source.data_endpoint) |
111 endpoint = data | 115 endpoint = data |
112 for e in endpoint_bits[:-1]: | 116 for e in endpoint_bits[:-1]: |
113 if e not in endpoint: | 117 if e not in endpoint: |
114 endpoint[e] = {} | 118 endpoint[e] = {} |
115 endpoint = endpoint[e] | 119 endpoint = endpoint[e] |