本文整理汇总了Python中pyramid.threadlocal.manager.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_it_with_registry
def test_it_with_registry(self):
from pyramid.registry import Registry
from pyramid.threadlocal import manager
registry = Registry()
self._callFUT(registry=registry)
current = manager.get()
self.assertEqual(current['registry'], registry)
开发者ID:AdamG,项目名称:pyramid,代码行数:7,代码来源:test_testing.py
示例2: test_it_with_request
def test_it_with_request(self):
from pyramid.threadlocal import manager
request = object()
self._callFUT(request=request)
current = manager.get()
self.assertEqual(current["request"], request)
开发者ID:pyramidcn,项目名称:pyramid,代码行数:7,代码来源:test_testing.py
示例3: test_miss_w_persistent_context
def test_miss_w_persistent_context(self):
from pyramid.threadlocal import manager
context = self._makeContext(_p_jar=object())
request = self._makeRequest(context=context)
manager.get()['request'] = request
environ = request.environ
credentials = {'login': 'login', 'password': 'bogus'}
plugin = self._makeOne()
self.assertEqual(plugin.authenticate(environ, credentials), None)
开发者ID:marcinkuzminski,项目名称:cartouche,代码行数:9,代码来源:test_whoplugin.py
示例4: test_it_with_request
def test_it_with_request(self):
from zope.component import getSiteManager
from pyramid.threadlocal import manager
request = object()
try:
self._callFUT(request=request)
current = manager.get()
self.assertEqual(current['request'], request)
finally:
getSiteManager.reset()
manager.clear()
开发者ID:SMFOSS,项目名称:pyramid,代码行数:11,代码来源:test_testing.py
示例5: test_it_with_registry
def test_it_with_registry(self):
from pyramid.registry import Registry
from zope.component import getSiteManager
from pyramid.threadlocal import manager
registry = Registry()
try:
self._callFUT(registry=registry)
current = manager.get()
self.assertEqual(current['registry'], registry)
finally:
getSiteManager.reset()
manager.clear()
开发者ID:SMFOSS,项目名称:pyramid,代码行数:12,代码来源:test_testing.py
示例6: test_it_defaults
def test_it_defaults(self):
from pyramid.threadlocal import manager
from pyramid.threadlocal import get_current_registry
from pyramid.registry import Registry
old = True
manager.push(old)
config = self._callFUT()
current = manager.get()
self.assertFalse(current is old)
self.assertEqual(config.registry, current['registry'])
self.assertEqual(current['registry'].__class__, Registry)
self.assertEqual(current['request'], None)
self._assertSMHook(get_current_registry)
开发者ID:AdamG,项目名称:pyramid,代码行数:13,代码来源:test_testing.py
示例7: test_hit_w_persistent_context_non_root
def test_hit_w_persistent_context_non_root(self):
from pyramid.threadlocal import manager
root = self._makeContext(_p_jar=object())
self._populate(root)
context = self._makeContext(_p_jar=object(),
__parent__=root,
cartouche=object(), # ignored
)
request = self._makeRequest(context=context)
manager.get()['request'] = request
environ = request.environ
credentials = {'login': 'login', 'password': 'password'}
plugin = self._makeOne()
self.assertEqual(plugin.authenticate(environ, credentials), 'UUID')
开发者ID:marcinkuzminski,项目名称:cartouche,代码行数:14,代码来源:test_whoplugin.py
示例8: _threadContext
def _threadContext(self):
# IMPORTANT: this assumes that APScheduler invokes jobs in a separate
# thread per job (as documented)...
# TODO: this needs confirmation!
if self.appreg is None:
yield
else:
from pyramid.threadlocal import manager
reg = dict(manager.get())
reg['registry'] = self.appreg
manager.push(reg)
try:
yield
finally:
manager.pop()
开发者ID:cadithealth,项目名称:pyramid_scheduler,代码行数:15,代码来源:scheduler.py
示例9: test_registry_cannot_be_inited
def test_registry_cannot_be_inited(self):
from pyramid.threadlocal import manager
registry = DummyRegistry()
def raiseit(name):
raise TypeError
registry.__init__ = raiseit
old = {'registry':registry}
try:
manager.push(old)
self._callFUT() # doesn't blow up
current = manager.get()
self.assertNotEqual(current, old)
self.assertEqual(registry.inited, 1)
finally:
manager.clear()
开发者ID:AdamG,项目名称:pyramid,代码行数:15,代码来源:test_testing.py
示例10: test_defaults
def test_defaults(self):
from pyramid.threadlocal import manager
registry = DummyRegistry()
old = {'registry':registry}
hook = lambda *arg: None
try:
self._setSMHook(hook)
manager.push(old)
self._callFUT()
current = manager.get()
self.assertNotEqual(current, old)
self.assertEqual(registry.inited, 2)
finally:
result = getSiteManager.sethook(None)
self.assertNotEqual(result, hook)
开发者ID:jvanasco,项目名称:pyramid,代码行数:15,代码来源:test_testing.py
示例11: test_it_defaults
def test_it_defaults(self):
from pyramid.threadlocal import manager
from pyramid.threadlocal import get_current_registry
from pyramid.registry import Registry
from zope.component import getSiteManager
old = True
manager.push(old)
try:
config = self._callFUT()
current = manager.get()
self.failIf(current is old)
self.assertEqual(config.registry, current['registry'])
self.assertEqual(current['registry'].__class__, Registry)
self.assertEqual(current['request'], None)
finally:
result = getSiteManager.sethook(None)
self.assertEqual(result, get_current_registry)
getSiteManager.reset()
manager.clear()
开发者ID:SMFOSS,项目名称:pyramid,代码行数:19,代码来源:test_testing.py
示例12: setUp
def setUp(self):
from pyramid.threadlocal import manager
self.manager = manager
self.default = manager.get()
开发者ID:7924102,项目名称:pyramid,代码行数:4,代码来源:test_scripting.py
注:本文中的pyramid.threadlocal.manager.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论