本文整理汇总了Python中scanner.Scanner.storage方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.storage方法的具体用法?Python Scanner.storage怎么用?Python Scanner.storage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner.Scanner
的用法示例。
在下文中一共展示了Scanner.storage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import storage [as 别名]
def __init__(self, storage,
conf_resource=None,
factory=None,
scan_interval=10,
pool_size=7,
cache_size=400,
cache_deactivate_after=60,
version_pool_size=3,
version_cache_size=100,
version_cache_deactivate_after=10,
**kw
):
"""Create an object database.
"""
if conf_resource is None:
if factory is not None:
# Use a configuration factory
conf, connections = call_conf_factory(factory, kw)
conf_resource = StaticResource(conf)
else:
if kw:
raise ConfigurationError('Extra keyword args: %s' % kw)
if isinstance(storage, ApeStorage):
# Use the configuration from the storage
conf_resource = storage.conf_resource
else:
raise ConfigurationError(
'No configuration or factory specified')
else:
# conf_resource was specified
if kw:
raise ConfigurationError('Extra keyword args: %s' % kw)
assert IResourceAccess.isImplementedBy(conf_resource)
assert factory is None
# Allocate locks:
l = RLock()
self._a=l.acquire
self._r=l.release
# Setup connection pools and cache info
self._pools={}
self._temps=[]
self._pool_size=pool_size
self._cache_size=cache_size
self._cache_deactivate_after = cache_deactivate_after
self._version_pool_size=version_pool_size
self._version_cache_size=version_cache_size
self._version_cache_deactivate_after = version_cache_deactivate_after
self._miv_cache={}
# Setup storage
self._storage=storage
storage.registerDB(self)
if not hasattr(storage,'tpc_vote'): storage.tpc_vote=lambda *args: None
self._conf_resource = conf_resource
scan_interval = int(scan_interval)
if scan_interval > 0:
from scanner import PoolScanControl, Scanner
pool_ctl = PoolScanControl(storage, db=self, scan_interval=scan_interval)
self.pool_scan_ctl = pool_ctl
scanner = Scanner()
storage.scanner = scanner
scanner.storage = storage
else:
self._scan_ctl = None
# Pass through methods:
self.history = storage.history
if hasattr(storage, 'undoInfo'):
self.undoInfo=storage.undoInfo
# Create the root object if it doesn't exist
c = self.open()
try:
c._prepare_root()
finally:
c.close()