當前位置: 首頁>>代碼示例>>Python>>正文


Python threadlocal.get_current_registry方法代碼示例

本文整理匯總了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 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:23,代碼來源:data_manager.py

示例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 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:16,代碼來源:subscribers.py

示例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] 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:9,代碼來源:classification.py

示例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} 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:16,代碼來源:panels.py

示例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) 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:14,代碼來源:social_login.py

示例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) 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:13,代碼來源:social_login.py

示例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) 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:14,代碼來源:social_login.py

示例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() 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:9,代碼來源:catalog.py

示例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() 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:9,代碼來源:catalog.py

示例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() 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:9,代碼來源:catalog.py

示例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() 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:9,代碼來源:catalog.py

示例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() 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:9,代碼來源:catalog.py

示例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() 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:9,代碼來源:catalog.py

示例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 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:13,代碼來源:catalog.py

示例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 
開發者ID:ecreall,項目名稱:lagendacommun,代碼行數:13,代碼來源:catalog.py


注:本文中的pyramid.threadlocal.get_current_registry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。