当前位置: 首页>>代码示例>>Python>>正文


Python peewee.Proxy方法代码示例

本文整理汇总了Python中peewee.Proxy方法的典型用法代码示例。如果您正苦于以下问题:Python peewee.Proxy方法的具体用法?Python peewee.Proxy怎么用?Python peewee.Proxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在peewee的用法示例。


在下文中一共展示了peewee.Proxy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_proxy_database

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def test_proxy_database(self):
        loop = asyncio.new_event_loop()
        database = peewee.Proxy()
        TestModel._meta.database = database
        objects = peewee_async.Manager(database, loop=loop)

        async def test(objects):
            text = "Test %s" % uuid.uuid4()
            await objects.create(TestModel, text=text)
            await objects.get(TestModel, text=text)

        for key in DB_CLASSES:
            params = DB_DEFAULTS.get(key) or {}
            params.update(DB_OVERRIDES.get(key) or {})
            database.initialize(DB_CLASSES[key](**params))

            TestModel.create_table(True)
            loop.run_until_complete(test(objects))
            loop.run_until_complete(objects.close())
            TestModel.drop_table(True)

        loop.close() 
开发者ID:05bit,项目名称:peewee-async,代码行数:24,代码来源:__init__.py

示例2: add_to_class

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def add_to_class(self, model_class, name):
        if isinstance(self._through_model, Proxy):
            def callback(through_model):
                self._through_model = through_model
                self.add_to_class(model_class, name)

            self._through_model.attach_callback(callback)
            return
        elif isinstance(self._through_model, DeferredThroughModel):
            self._through_model.set_field(model_class, self, name)
            return

        self.name = name
        self.model_class = model_class
        if not self.verbose_name:
            self.verbose_name = re.sub('_+', ' ', name).title()
        setattr(model_class, name, self._get_descriptor())

        if not self._is_backref:
            backref = AioManyToManyField(
                self.model_class,
                through_model=self._through_model,
                _is_backref=True)
            related_name = self._related_name or model_class._meta.name + 's'
            backref.add_to_class(self.rel_model, related_name) 
开发者ID:kszucs,项目名称:aiopeewee,代码行数:27,代码来源:fields.py

示例3: __init__

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def __init__(self, engine_cls, instance, *args, **kwargs):
		"""
		Initiate database.

		:param engine_cls: Engine class
		:param instance: Instance of the app.
		:param args: *
		:param kwargs: **
		:type instance: pyplanet.core.instance.Instance
		"""
		self.engine = engine_cls(*args, **kwargs)
		self.instance = instance
		self.migrator = Migrator(self.instance, self)
		self.registry = Registry(self.instance, self)
		self.objects = peewee_async.Manager(self.engine, loop=self.instance.loop)

		# Don't allow any sync code.
		if hasattr(self.engine, 'allow_sync'):
			self.engine.allow_sync = False

		Proxy.initialize(self.engine) 
开发者ID:PyPlanet,项目名称:PyPlanet,代码行数:23,代码来源:database.py

示例4: _load_database

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def _load_database(self, app, config_value):
        if isinstance(config_value, Database):
            database = config_value
        elif isinstance(config_value, dict):
            database = self._load_from_config_dict(dict(config_value))
        else:
            # Assume a database connection URL.
            database = db_url_connect(config_value)

        if isinstance(self.database, Proxy):
            self.database.initialize(database)
        else:
            self.database = database 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:15,代码来源:flask_utils.py

示例5: Model

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def Model(self):
        if self._app is None:
            database = getattr(self, 'database', None)
            if database is None:
                self.database = Proxy()

        if not hasattr(self, '_model_class'):
            self._model_class = self.get_model_class()
        return self._model_class 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:11,代码来源:flask_utils.py

示例6: _read_only_config

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def _read_only_config(cls):
        read_only_config = getattr(cls._meta, "read_only_config", None)
        if read_only_config is None:
            return ReadOnlyConfig(False, [])

        if isinstance(read_only_config, Proxy) and read_only_config.obj is None:
            return ReadOnlyConfig(False, [])

        return read_only_config.obj or ReadOnlyConfig(False, []) 
开发者ID:quay,项目名称:quay,代码行数:11,代码来源:readreplica.py

示例7: test_get_model_supported

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def test_get_model_supported(version):
    M = model.get_model(version)
    assert M
    assert M.database_proxy
    assert isinstance(M.database_proxy, peewee.Proxy) 
开发者ID:tracboat,项目名称:tracboat,代码行数:7,代码来源:test_model.py

示例8: DBProxy

# 需要导入模块: import peewee [as 别名]
# 或者: from peewee import Proxy [as 别名]
def DBProxy():
        if not PWDatabase.__proxy:
            PWDatabase.__proxy = Proxy()
        return PWDatabase.__proxy 
开发者ID:CityOfZion,项目名称:neo-python,代码行数:6,代码来源:PWDatabase.py


注:本文中的peewee.Proxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。