comparison piecrust/sources/fs.py @ 1156:4ea64255eadf

sources: Add ability to force a realm on a source.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 11 Jun 2019 15:12:47 -0700
parents a6618fdab37e
children
comparison
equal deleted inserted replaced
1155:fac4483867a5 1156:4ea64255eadf
1 import os.path 1 import os.path
2 import re 2 import re
3 import glob 3 import glob
4 import fnmatch 4 import fnmatch
5 import logging 5 import logging
6 from werkzeug.utils import cached_property
6 from piecrust import osutil 7 from piecrust import osutil
7 from piecrust.routing import RouteParameter 8 from piecrust.routing import RouteParameter
8 from piecrust.sources.base import ( 9 from piecrust.sources.base import (
9 ContentItem, ContentGroup, ContentSource, 10 ContentItem, ContentGroup, ContentSource,
10 REL_PARENT_GROUP, REL_LOGICAL_PARENT_ITEM, REL_LOGICAL_CHILD_GROUP) 11 REL_PARENT_GROUP, REL_LOGICAL_PARENT_ITEM, REL_LOGICAL_CHILD_GROUP)
32 def __init__(self, app, name, config): 33 def __init__(self, app, name, config):
33 super().__init__(app, name, config) 34 super().__init__(app, name, config)
34 self.fs_endpoint = config.get('fs_endpoint', name) 35 self.fs_endpoint = config.get('fs_endpoint', name)
35 self.fs_endpoint_path = os.path.join(self.root_dir, self.fs_endpoint) 36 self.fs_endpoint_path = os.path.join(self.root_dir, self.fs_endpoint)
36 37
37 @property 38 @cached_property
38 def root_dir(self): 39 def root_dir(self):
39 if self.is_theme_source: 40 if self.is_theme_source and not self.config.get('force_user_realm'):
40 return self.app.theme_dir 41 return self.app.theme_dir
41 return self.app.root_dir 42 return self.app.root_dir
42 43
43 def _checkFSEndpoint(self): 44 def _checkFSEndpoint(self):
44 if not os.path.isdir(self.fs_endpoint_path): 45 if not os.path.isdir(self.fs_endpoint_path):