本文整理汇总了Python中sqlalchemy.util.column_dict函数的典型用法代码示例。如果您正苦于以下问题:Python column_dict函数的具体用法?Python column_dict怎么用?Python column_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了column_dict函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: replacement_traverse
def replacement_traverse(obj, opts, replace):
"""clone the given expression structure, allowing element replacement by a given replacement function."""
cloned = util.column_dict()
stop_on = util.column_set(opts.get('stop_on', []))
def clone(element):
newelem = replace(element)
if newelem is not None:
stop_on.add(newelem)
return newelem
if element not in cloned:
cloned[element] = element._clone()
return cloned[element]
obj = clone(obj)
stack = [obj]
while stack:
t = stack.pop()
if t in stop_on:
continue
t._copy_internals(clone=clone)
for c in t.get_children(**opts):
stack.append(c)
return obj
开发者ID:BwRy,项目名称:rcs-db-ext,代码行数:26,代码来源:visitors.py
示例2: __init__
def __init__(self, selectable, equivalents=None, include=None, exclude=None, adapt_on_names=False):
self.__traverse_options__ = {'stop_on':[selectable]}
self.selectable = selectable
self.include = include
self.exclude = exclude
self.equivalents = util.column_dict(equivalents or {})
self.adapt_on_names = adapt_on_names
开发者ID:Kellel,项目名称:items,代码行数:7,代码来源:util.py
示例3: cloned_traverse
def cloned_traverse(obj, opts, visitors):
"""clone the given expression structure, allowing modifications by visitors."""
cloned = util.column_dict()
def clone(element):
if element not in cloned:
cloned[element] = element._clone()
return cloned[element]
obj = clone(obj)
stack = [obj]
while stack:
t = stack.pop()
if t in cloned:
continue
t._copy_internals(clone=clone)
meth = visitors.get(t.__visit_name__, None)
if meth:
meth(t)
for c in t.get_children(**opts):
stack.append(c)
return obj
开发者ID:BwRy,项目名称:rcs-db-ext,代码行数:26,代码来源:visitors.py
示例4: _deep_annotate
def _deep_annotate(element, annotations, exclude=None):
"""Deep copy the given ClauseElement, annotating each element
with the given annotations dictionary.
Elements within the exclude collection will be cloned but not annotated.
"""
cloned = util.column_dict()
def clone(elem):
# check if element is present in the exclude list.
# take into account proxying relationships.
if elem in cloned:
return cloned[elem]
elif exclude and \
hasattr(elem, 'proxy_set') and \
elem.proxy_set.intersection(exclude):
newelem = elem._clone()
elif annotations != elem._annotations:
newelem = elem._annotate(annotations)
else:
newelem = elem
newelem._copy_internals(clone=clone)
cloned[elem] = newelem
return newelem
if element is not None:
element = clone(element)
return element
开发者ID:Kellel,项目名称:items,代码行数:29,代码来源:util.py
示例5: replacement_traverse
def replacement_traverse(obj, opts, replace):
"""clone the given expression structure, allowing element
replacement by a given replacement function."""
cloned = util.column_dict()
stop_on = util.column_set(opts.get('stop_on', []))
def clone(elem, **kw):
if elem in stop_on or \
'no_replacement_traverse' in elem._annotations:
return elem
else:
newelem = replace(elem)
if newelem is not None:
stop_on.add(newelem)
return newelem
else:
if elem not in cloned:
cloned[elem] = newelem = elem._clone()
newelem._copy_internals(clone=clone, **kw)
return cloned[elem]
if obj is not None:
obj = clone(obj, **opts)
return obj
开发者ID:EchelonFour,项目名称:CouchPotatoServer,代码行数:25,代码来源:visitors.py
示例6: construct_params
def construct_params(self, params=None):
"""return a dictionary of bind parameter keys and values"""
if params:
params = util.column_dict(params)
pd = {}
for bindparam, name in self.bind_names.iteritems():
for paramname in (bindparam.key, bindparam.shortname, name):
if paramname in params:
pd[name] = params[paramname]
break
else:
if util.callable(bindparam.value):
pd[name] = bindparam.value()
else:
pd[name] = bindparam.value
return pd
else:
pd = {}
for bindparam in self.bind_names:
if util.callable(bindparam.value):
pd[self.bind_names[bindparam]] = bindparam.value()
else:
pd[self.bind_names[bindparam]] = bindparam.value
return pd
开发者ID:xihadajiang,项目名称:test,代码行数:25,代码来源:compiler.py
示例7: __init__
def __init__(self, class_, *columns, **kwargs):
if "comparator" in kwargs:
util.warn_deprecated(
"The 'comparator' argument to CompositeProperty is deprecated. Use comparator_factory."
)
kwargs["comparator_factory"] = kwargs["comparator"]
super(CompositeProperty, self).__init__(*columns, **kwargs)
self._col_position_map = util.column_dict((c, i) for i, c in enumerate(columns))
self.composite_class = class_
self.strategy_class = strategies.CompositeColumnLoader
开发者ID:AntonNguyen,项目名称:easy_api,代码行数:10,代码来源:properties.py
示例8: _create_lazy_clause
def _create_lazy_clause(cls, prop, reverse_direction=False):
binds = util.column_dict()
lookup = util.column_dict()
equated_columns = util.column_dict()
if reverse_direction and prop.secondaryjoin is None:
for l, r in prop.local_remote_pairs:
_list = lookup.setdefault(r, [])
_list.append((r, l))
equated_columns[l] = r
else:
for l, r in prop.local_remote_pairs:
_list = lookup.setdefault(l, [])
_list.append((l, r))
equated_columns[r] = l
def col_to_bind(col):
if col in lookup:
for tobind, equated in lookup[col]:
if equated in binds:
return None
if col not in binds:
binds[col] = sql.bindparam(None, None, type_=col.type)
return binds[col]
return None
lazywhere = prop.primaryjoin
if prop.secondaryjoin is None or not reverse_direction:
lazywhere = visitors.replacement_traverse(
lazywhere, {}, col_to_bind)
if prop.secondaryjoin is not None:
secondaryjoin = prop.secondaryjoin
if reverse_direction:
secondaryjoin = visitors.replacement_traverse(
secondaryjoin, {}, col_to_bind)
lazywhere = sql.and_(lazywhere, secondaryjoin)
bind_to_col = dict((binds[col].key, col) for col in binds)
return lazywhere, bind_to_col, equated_columns
开发者ID:jsmiller84,项目名称:CouchPotato,代码行数:42,代码来源:strategies.py
示例9: _deep_deannotate
def _deep_deannotate(element):
"""Deep copy the given element, removing all annotations."""
cloned = util.column_dict()
def clone(elem):
if elem not in cloned:
newelem = elem._deannotate()
newelem._copy_internals(clone=clone)
cloned[elem] = newelem
return cloned[elem]
if element is not None:
element = clone(element)
return element
开发者ID:Kellel,项目名称:items,代码行数:15,代码来源:util.py
示例10: cloned_traverse
def cloned_traverse(obj, opts, visitors):
"""clone the given expression structure, allowing
modifications by visitors."""
cloned = util.column_dict()
stop_on = util.column_set(opts.get('stop_on', []))
def clone(elem):
if elem in stop_on:
return elem
else:
if elem not in cloned:
cloned[elem] = newelem = elem._clone()
newelem._copy_internals(clone=clone)
meth = visitors.get(newelem.__visit_name__, None)
if meth:
meth(newelem)
return cloned[elem]
if obj is not None:
obj = clone(obj)
return obj
开发者ID:EchelonFour,项目名称:CouchPotatoServer,代码行数:22,代码来源:visitors.py
示例11: __init__
def __init__(self, selectable, equivalents=None, include=None, exclude=None):
self.__traverse_options__ = {"stop_on": [selectable]}
self.selectable = selectable
self.include = include
self.exclude = exclude
self.equivalents = util.column_dict(equivalents or {})
开发者ID:pszafer,项目名称:dlna_upnp_invention,代码行数:6,代码来源:util.py
注:本文中的sqlalchemy.util.column_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论