本文整理汇总了Python中pyramid.threadlocal.get_current_registry方法的典型用法代码示例。如果您正苦于以下问题:Python threadlocal.get_current_registry方法的具体用法?Python threadlocal.get_current_registry怎么用?Python threadlocal.get_current_registry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.threadlocal
的用法示例。
在下文中一共展示了threadlocal.get_current_registry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_object
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def create_object(content_type, args={}):
registry = get_current_registry()
factory = registry.content.content_types.get(content_type, None)
config = INTERFACES_CONFIG.get(content_type, None)
if not factory or not config:
return args
interface = config.get('interface', None)
deserializer = config.get('deserializer', None)
obj = None
if interface:
result = {a: create_attr_obj(interface[a], args.get(a))
for a in interface if a in args and
isinstance(interface[a], Attribute)}
result.update({a: args.get(a) for a in args if a not in interface})
deserialized_args = deserializer(result)
obj = factory(**deserialized_args)
else:
obj = factory(**args)
return obj
示例2: mysubscriber
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def mysubscriber(event):
"""Add the lac catalog when the root is added."""
root = event.object
registry = get_current_registry()
settings = registry.settings
lac_title = settings.get('lac.title')
root.title = lac_title
catalogs = find_service(root, 'catalogs')
catalogs.add_catalog('lac')
default_site = SiteFolder(title="Création culturelle")
default_site.urls_ids = PersistentList(DEFAULT_SITE_ID)
root.addtoproperty('site_folders', default_site)
add_storage_to_root(root, registry)
root.default_site = default_site
示例3: _getattribute
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def _getattribute(self, value, **args):
adapter = get_current_registry().queryAdapter(value, ISearchableObject)
if adapter is None:
return [(value, self.default_value)]
cities = adapter.object_city()
return [(value, c.title()) for c in cities]
示例4: __call__
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def __call__(self):
root = getSite()
if not global_user_processsecurity(None, root):
return {'error': True}
dace_ui_api = get_current_registry().getUtility(IDaceUIAPI,
'dace_ui_api')
actions = dace_ui_api.get_actions([root], self.request)
admin_actions = [a for a in actions
if getattr(a[1], 'style_descriminator', '') ==
'admin-action']
return {'groups': group_actions(admin_actions),
'pictos': {g: v[1] for g, v in GROUPS_PICTO.items()},
'error': False}
示例5: add_site_facebook_login
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def add_site_facebook_login(site, app):
registry = get_current_registry()
config = Configurator(registry=registry, autocommit=True)
name = app.application_site_id
add_facebook_login(
config,
consumer_key=getattr(app, 'consumer_key', ''),
consumer_secret=getattr(app, 'consumer_secret', ''),
scope=getattr(app, 'scop', ''),
login_path='/login/'+name,
callback_path='/login/'+name+'/callback',
name=name)
示例6: add_site_twitter_login
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def add_site_twitter_login(site, app):
registry = get_current_registry()
config = Configurator(registry=registry, autocommit=True)
name = app.application_site_id
add_twitter_login(
config,
consumer_key=getattr(app, 'consumer_key', ''),
consumer_secret=getattr(app, 'consumer_secret', ''),
login_path='/login/'+name,
callback_path='/login/'+name+'/callback',
name=name)
示例7: add_site_google_login
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def add_site_google_login(site, app):
registry = get_current_registry()
config = Configurator(registry=registry, autocommit=True)
name = app.application_site_id
add_google_login(
config,
consumer_key=getattr(app, 'consumer_key', ''),
consumer_secret=getattr(app, 'consumer_secret', ''),
scope=getattr(app, 'scope', ''),
login_path='/login/'+name,
callback_path='/login/'+name+'/callback',
name=name)
示例8: release_date
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def release_date(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
return adapter.release_date()
示例9: publication_end_date
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def publication_end_date(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
return adapter.publication_end_date()
示例10: start_date
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def start_date(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
return adapter.start_date()
示例11: end_date
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def end_date(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
return adapter.end_date()
示例12: object_keywords
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def object_keywords(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
return adapter.object_keywords()
示例13: object_authors
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def object_authors(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
return adapter.object_authors()
示例14: created_at
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def created_at(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
created_at = adapter.created_at()
if created_at is None:
return default
return created_at
示例15: modified_at
# 需要导入模块: from pyramid import threadlocal [as 别名]
# 或者: from pyramid.threadlocal import get_current_registry [as 别名]
def modified_at(self, default):
adapter = get_current_registry().queryAdapter(
self.resource, ISearchableObject)
if adapter is None:
return default
modified_at = adapter.modified_at()
if modified_at is None:
return default
return modified_at