Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@reify
def _conn(self):
"""The Memcached connection, cached for this call"""
return memcache.Client(self.servers)
@reify
def stage(self):
return self.getstage(self.username, self.index)
@reify
def _settings(self): # pragma: no cover
s = Settings('org.pylonsproject.kotti.ScaffoldDefaults')
s.add_setting("author", unicode, default='')
s.add_setting("email", str, default='')
s.add_setting("gh_user", str, '')
s.load_settings() # loads anything that might be saved
return s
@reify
def path_query(self):
return Eq('path', resource_path(self.context))
@reify
def system_catalog(self):
return find_catalog(self.context, 'system')
@reify
def edit_links(self):
if not hasattr(self.context, "type_info"):
return []
return [
l
for l in self.context.type_info.edit_links
if l.visible(self.context, self.request)
]
@reify
def userid(self):
return authenticated_userid(self)
@reify
def devmode(self):
"""Let templates know if we are in devmode, for comments """
sn = 'bottlecap.devmode'
dm = self.request.registry.settings.get(sn, "false")
return dm == "true"
@reify
def _fields(self) -> dict:
fields = defaultdict(dict)
for node in self.schema.children:
field = node.name
if not hasattr(node, 'reftype'):
fields['data'][field] = node
elif not node.backref:
fields['reference'][field] = node
else:
fields['back_reference'][field] = node
if getattr(node, 'readonly', False):
fields['readonly'][field] = node
return fields
@reify
def viewable_sheets(self):
sheets = {}
for ifacename, sheet in self.sheets.items():
permission = sheet.view_permission
if has_permission(permission, self.context, self.request):
sheets[ifacename] = sheet
return sheets