本文整理汇总了Python中types.ModuleType.metadata方法的典型用法代码示例。如果您正苦于以下问题:Python ModuleType.metadata方法的具体用法?Python ModuleType.metadata怎么用?Python ModuleType.metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.ModuleType
的用法示例。
在下文中一共展示了ModuleType.metadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _make_module
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import metadata [as 别名]
def _make_module():
db = ModuleType('db')
_get_items = lambda mod: ((key, getattr(mod, key)) for key in mod.__all__)
modules = (_get_items(sqlalchemy), _get_items(orm))
for module in modules:
for key, value in module:
setattr(db, key, value)
# support for postgresql array type
from sqlalchemy.dialects.postgresql.base import PGArray
db.PGArray = PGArray
db.get_engine = get_engine
db.session = session
db.metadata = metadata
db.mapper = mapper
db.atomic_add = atomic_add
db.no_autoflush = no_autoflush
db.find_next_increment = find_next_increment
db.select_blocks = select_blocks
db.driver = driver
db.Model = Model
db.Query = Query
db.File = File
db.SlugGenerator = SlugGenerator
db.GuidGenerator = GuidGenerator
db.AttributeExtension = AttributeExtension
db.ColumnProperty = orm.ColumnProperty
db.NoResultFound = orm.exc.NoResultFound
db.SQLAlchemyError = exc.SQLAlchemyError
return db
示例2: _make_module
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import metadata [as 别名]
def _make_module():
db = ModuleType('db')
for mod in sqlalchemy, orm:
for key, value in mod.__dict__.iteritems():
if key in mod.__all__:
setattr(db, key, value)
db.session = session
db.metadata = metadata
db.Model = Model
db.NoResultFound = orm.exc.NoResultFound
return db