• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.symbol函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sqlalchemy.util.symbol函数的典型用法代码示例。如果您正苦于以下问题:Python symbol函数的具体用法?Python symbol怎么用?Python symbol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_bitflags

    def test_bitflags(self):
        sym1 = util.symbol('sym1', canonical=1)
        sym2 = util.symbol('sym2', canonical=2)

        assert sym1 & sym1
        assert not sym1 & sym2
        assert not sym1 & sym1 & sym2
开发者ID:MVReddy,项目名称:sqlalchemy,代码行数:7,代码来源:test_utils.py


示例2: _on_field_change

 def _on_field_change(offer, value, old_value, initiator):
     if old_value == symbol('NO_VALUE') or old_value == symbol('NEVER_SET'):
         old_value = None
     if offer.offer_id and value != old_value and old_value is not None:
         log = OfferLog(offer=offer)
         log.offer_id = offer.offer_id
         setattr(log, field, old_value)
         db.session.add(log)
         db.session.commit()
开发者ID:xmas11,项目名称:braincode2016-sambastic,代码行数:9,代码来源:flaskapp.py


示例3: set_banner_fileUpload

def set_banner_fileUpload(target, value, oldvalue, initiator):
    """ Delete banner file when set

    This function is called every time the banner fileupload
    attribute is set. The function deletes the old image file
    when the fileupload attribute is set to a new value
    (a new image file is uploaded).
    
    """
    if oldvalue != symbol("NO_VALUE") and oldvalue != symbol("NEVER_SET") and value != oldvalue:
        os.remove(os.path.join(app.config["UPLOAD_FOLDER"], oldvalue))
开发者ID:nijor,项目名称:PKSU-reklame,代码行数:11,代码来源:model.py


示例4: test_composites

    def test_composites(self):
        sym1 = util.symbol('sym1', canonical=1)
        sym2 = util.symbol('sym2', canonical=2)
        sym3 = util.symbol('sym3', canonical=4)
        sym4 = util.symbol('sym4', canonical=8)

        assert sym1 & (sym2 | sym1 | sym4)
        assert not sym1 & (sym2 | sym3)

        assert not (sym1 | sym2) & (sym3 | sym4)
        assert (sym1 | sym2) & (sym2 | sym4)
开发者ID:MVReddy,项目名称:sqlalchemy,代码行数:11,代码来源:test_utils.py


示例5: test_basic

    def test_basic(self):
        sym1 = util.symbol('foo')
        assert sym1.name == 'foo'
        sym2 = util.symbol('foo')

        assert sym1 is sym2
        assert sym1 == sym2

        sym3 = util.symbol('bar')
        assert sym1 is not sym3
        assert sym1 != sym3
开发者ID:ContextLogic,项目名称:sqlalchemy,代码行数:11,代码来源:test_utils.py


示例6: test_pickle

    def test_pickle(self):
        sym1 = util.symbol('foo')
        sym2 = util.symbol('foo')

        assert sym1 is sym2

        # default
        s = util.pickle.dumps(sym1)
        sym3 = util.pickle.loads(s)

        for protocol in 0, 1, 2:
            print protocol
            serial = util.pickle.dumps(sym1)
            rt = util.pickle.loads(serial)
            assert rt is sym1
            assert rt is sym2
开发者ID:ContextLogic,项目名称:sqlalchemy,代码行数:16,代码来源:test_utils.py


示例7: _install_lookup_strategy

def _install_lookup_strategy(implementation):
    """Replace global class/object management functions
    with either faster or more comprehensive implementations,
    based on whether or not extended class instrumentation
    has been detected.

    This function is called only by InstrumentationRegistry()
    and unit tests specific to this behavior.

    """
    global instance_state, instance_dict, manager_of_class
    if implementation is util.symbol('native'):
        instance_state = attrgetter(ClassManager.STATE_ATTR)
        instance_dict = attrgetter("__dict__")
        def manager_of_class(cls):
            return cls.__dict__.get(ClassManager.MANAGER_ATTR, None)
    else:
        instance_state = instrumentation_registry.state_of
        instance_dict = instrumentation_registry.dict_of
        manager_of_class = instrumentation_registry.manager_of_class
    attributes.instance_state = instance_state
    attributes.instance_dict = instance_dict
    attributes.manager_of_class = manager_of_class
开发者ID:BeegorMif,项目名称:maraschino,代码行数:23,代码来源:instrumentation.py


示例8:

This module is usually not directly visible to user applications, but
defines a large part of the ORM's interactivity.


"""

import operator
from operator import itemgetter

from sqlalchemy import util, event, exc as sa_exc
from sqlalchemy.orm import interfaces, collections, events


mapperutil = util.importlater("sqlalchemy.orm", "util")

PASSIVE_NO_RESULT = util.symbol('PASSIVE_NO_RESULT')
ATTR_WAS_SET = util.symbol('ATTR_WAS_SET')
ATTR_EMPTY = util.symbol('ATTR_EMPTY')
NO_VALUE = util.symbol('NO_VALUE')
NEVER_SET = util.symbol('NEVER_SET')

PASSIVE_RETURN_NEVER_SET = util.symbol('PASSIVE_RETURN_NEVER_SET'
"""Symbol indicating that loader callables can be 
fired off, but if no callable is applicable and no value is
present, the attribute should remain non-initialized.
NEVER_SET is returned in this case.
""")

PASSIVE_NO_INITIALIZE = util.symbol('PASSIVE_NO_INITIALIZE',
"""Symbol indicating that loader callables should
   not be fired off, and a non-initialized attribute 
开发者ID:MorganBorman,项目名称:cxsbs,代码行数:31,代码来源:attributes.py


示例9: list

        return list(self)

    def __repr__(self):
        return repr(list(self))

    def __hash__(self):
        raise TypeError("%s objects are unhashable" % type(self).__name__)

    for func_name, func in list(locals().items()):
        if (util.callable(func) and func.__name__ == func_name and
            not func.__doc__ and hasattr(list, func_name)):
            func.__doc__ = getattr(list, func_name).__doc__
    del func_name, func


_NotProvided = util.symbol('_NotProvided')
class _AssociationDict(_AssociationCollection):
    """Generic, converting, dict-to-dict proxy."""

    def _create(self, key, value):
        return self.creator(key, value)

    def _get(self, object):
        return self.getter(object)

    def _set(self, object, key, value):
        return self.setter(object, key, value)

    def __getitem__(self, key):
        return self._get(self.col[key])
开发者ID:MAVProxyUser,项目名称:wdx-before-2017,代码行数:30,代码来源:associationproxy.py


示例10: _set_decorators

def _set_decorators():
    """Tailored instrumentation wrappers for any set-like class."""

    def _tidy(fn):
        setattr(fn, '_sa_instrumented', True)
        fn.__doc__ = getattr(getattr(set, fn.__name__), '__doc__')

    Unspecified = util.symbol('Unspecified')

    def add(fn):
        def add(self, value, _sa_initiator=None):
            if value not in self:
                value = __set(self, value, _sa_initiator)
            # testlib.pragma exempt:__hash__
            fn(self, value)
        _tidy(add)
        return add

    if sys.version_info < (2, 4):
        def discard(fn):
            def discard(self, value, _sa_initiator=None):
                if value in self:
                    self.remove(value, _sa_initiator)
            _tidy(discard)
            return discard
    else:
        def discard(fn):
            def discard(self, value, _sa_initiator=None):
                # testlib.pragma exempt:__hash__
                if value in self:
                    __del(self, value, _sa_initiator)
                    # testlib.pragma exempt:__hash__
                fn(self, value)
            _tidy(discard)
            return discard

    def remove(fn):
        def remove(self, value, _sa_initiator=None):
            # testlib.pragma exempt:__hash__
            if value in self:
                __del(self, value, _sa_initiator)
            # testlib.pragma exempt:__hash__
            fn(self, value)
        _tidy(remove)
        return remove

    def pop(fn):
        def pop(self):
            __before_delete(self)
            item = fn(self)
            __del(self, item)
            return item
        _tidy(pop)
        return pop

    def clear(fn):
        def clear(self):
            for item in list(self):
                self.remove(item)
        _tidy(clear)
        return clear

    def update(fn):
        def update(self, value):
            for item in value:
                self.add(item)
        _tidy(update)
        return update

    def __ior__(fn):
        def __ior__(self, value):
            if not _set_binops_check_strict(self, value):
                return NotImplemented
            for item in value:
                self.add(item)
            return self
        _tidy(__ior__)
        return __ior__

    def difference_update(fn):
        def difference_update(self, value):
            for item in value:
                self.discard(item)
        _tidy(difference_update)
        return difference_update

    def __isub__(fn):
        def __isub__(self, value):
            if not _set_binops_check_strict(self, value):
                return NotImplemented
            for item in value:
                self.discard(item)
            return self
        _tidy(__isub__)
        return __isub__

    def intersection_update(fn):
        def intersection_update(self, other):
            want, have = self.intersection(other), set(self)
            remove, add = have - want, want - have
#.........这里部分代码省略.........
开发者ID:AntonNguyen,项目名称:easy_api,代码行数:101,代码来源:collections.py


示例11: Copyright

# sqlalchemy/event.py
# Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

"""Base event API."""

from sqlalchemy import util, exc

CANCEL = util.symbol("CANCEL")
NO_RETVAL = util.symbol("NO_RETVAL")


def listen(target, identifier, fn, *args, **kw):
    """Register a listener function for the given target.
    
    e.g.::
    
        from sqlalchemy import event
        from sqlalchemy.schema import UniqueConstraint
        
        def unique_constraint_name(const, table):
            const.name = "uq_%s_%s" % (
                table.name,
                list(const.columns)[0].name
            )
        event.listen(
                UniqueConstraint, 
                "after_parent_attach", 
                unique_constraint_name)
开发者ID:neonrush,项目名称:CouchPotatoServer,代码行数:31,代码来源:event.py


示例12: set

_commutative = set([eq, ne, add, mul])


def is_commutative(op):
    return op in _commutative


def is_ordering_modifier(op):
    return op in (asc_op, desc_op, nullsfirst_op, nullslast_op)


_associative = _commutative.union([concat_op, and_, or_])


_smallest = symbol("_smallest")
_largest = symbol("_largest")

_PRECEDENCE = {
    from_: 15,
    mul: 7,
    truediv: 7,
    # Py2K
    div: 7,
    # end Py2K
    mod: 7,
    neg: 7,
    add: 6,
    sub: 6,
    concat_op: 6,
    match_op: 6,
开发者ID:nonmoun,项目名称:kittypuppy,代码行数:30,代码来源:operators.py


示例13: _DBProxy

    try:
        return proxies[module]
    except KeyError:
        return proxies.setdefault(module, _DBProxy(module, **params))

def clear_managers():
    """Remove all current DB-API 2.0 managers.

    All pools and connections are disposed.
    """

    for manager in proxies.itervalues():
        manager.close()
    proxies.clear()

reset_rollback = util.symbol('reset_rollback')
reset_commit = util.symbol('reset_commit')
reset_none = util.symbol('reset_none')


class Pool(log.Identified):
    """Abstract base class for connection pools."""

    def __init__(self,
                    creator, recycle=-1, echo=None,
                    use_threadlocal=False,
                    logging_name=None,
                    reset_on_return=True,
                    listeners=None,
                    events=None,
                    _dispatch=None):
开发者ID:y2bishop2y,项目名称:microengine,代码行数:31,代码来源:pool.py


示例14: Copyright

# sqlalchemy/event.py
# Copyright (C) 2005-2013 the SQLAlchemy authors and contributors <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

"""Base event API."""

from sqlalchemy import util, exc
import weakref

CANCEL = util.symbol('CANCEL')
NO_RETVAL = util.symbol('NO_RETVAL')

def listen(target, identifier, fn, *args, **kw):
    """Register a listener function for the given target.

    e.g.::

        from sqlalchemy import event
        from sqlalchemy.schema import UniqueConstraint

        def unique_constraint_name(const, table):
            const.name = "uq_%s_%s" % (
                table.name,
                list(const.columns)[0].name
            )
        event.listen(
                UniqueConstraint,
                "after_parent_attach",
                unique_constraint_name)
开发者ID:Am3s,项目名称:CouchPotatoServer,代码行数:31,代码来源:event.py


示例15: Copyright

# attributes.py - manages object attributes
# Copyright (C) 2005, 2006, 2007, 2008 Michael Bayer [email protected]
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

import operator, weakref
from itertools import chain
import UserDict
from sqlalchemy import util
from sqlalchemy.orm import interfaces, collections
from sqlalchemy.orm.util import identity_equal
from sqlalchemy import exceptions

PASSIVE_NORESULT = util.symbol("PASSIVE_NORESULT")
ATTR_WAS_SET = util.symbol("ATTR_WAS_SET")
NO_VALUE = util.symbol("NO_VALUE")
NEVER_SET = util.symbol("NEVER_SET")


class InstrumentedAttribute(interfaces.PropComparator):
    """public-facing instrumented attribute, placed in the
    class dictionary.

    """

    def __init__(self, impl, comparator=None):
        """Construct an InstrumentedAttribute.
        comparator
          a sql.Comparator to which class-level compare/math events will be sent
        """
开发者ID:pombredanne,项目名称:sqlalchemy-patches,代码行数:31,代码来源:attributes.py


示例16: copy

    def copy(self):
        return list(self)

    def __repr__(self):
        return repr(list(self))

    def __hash__(self):
        raise TypeError("%s objects are unhashable" % type(self).__name__)

    for func_name, func in locals().items():
        if util.callable(func) and func.func_name == func_name and not func.__doc__ and hasattr(list, func_name):
            func.__doc__ = getattr(list, func_name).__doc__
    del func_name, func


_NotProvided = util.symbol("_NotProvided")


class _AssociationDict(_AssociationCollection):
    """Generic, converting, dict-to-dict proxy."""

    def _create(self, key, value):
        return self.creator(key, value)

    def _get(self, object):
        return self.getter(object)

    def _set(self, object, key, value):
        return self.setter(object, key, value)

    def __getitem__(self, key):
开发者ID:KonstantinStepanov,项目名称:flaskDb,代码行数:31,代码来源:associationproxy.py


示例17: teardown_class

 def teardown_class(cls):
     clear_mappers()
     instrumentation._install_lookup_strategy(util.symbol('native'))
开发者ID:ContextLogic,项目名称:sqlalchemy,代码行数:3,代码来源:test_extendedattr.py


示例18: set_only_once

def set_only_once(target, new_value, old_value, initiator):
    if old_value == new_value:
        return

    if old_value not in [None, symbol('NEVER_SET'), symbol('NO_VALUE')]:
        raise AttributeError("Attempted to set an immutable attribute")
开发者ID:genome,项目名称:ptero-lsf,代码行数:6,代码来源:job.py


示例19: _setup_crud_params

For more information on the PostgreSQL feature, see the
``ON CONFLICT` section of the `INSERT` statement in the PostgreSQL docs
<http://www.postgresql.org/docs/current/static/sql-insert.html#SQL-ON-CONFLICT>`_.
"""

import sqlalchemy.dialects.postgresql.base
from sqlalchemy.sql import compiler, expression, crud
from sqlalchemy import util
from sqlalchemy.sql.expression import ClauseElement, ColumnClause, ColumnElement
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.exc import CompileError
from sqlalchemy.schema import UniqueConstraint, PrimaryKeyConstraint, Index
from collections import Iterable

ISINSERT = util.symbol('ISINSERT')
ISUPDATE = util.symbol('ISUPDATE')
ISDELETE = util.symbol('ISDELETE')

def _setup_crud_params(compiler, stmt, local_stmt_type, **kw):
	restore_isinsert = compiler.isinsert
	restore_isupdate = compiler.isupdate
	restore_isdelete = compiler.isdelete

	should_restore = (
		restore_isinsert or restore_isupdate or restore_isdelete
	) or len(compiler.stack) > 1

	if local_stmt_type is ISINSERT:
		compiler.isupdate = False
		compiler.isinsert = True
开发者ID:pyrige,项目名称:lrrbot,代码行数:30,代码来源:sqlalchemy_pg95_upsert.py


示例20: _dict_decorators

def _dict_decorators():
    """Tailored instrumentation wrappers for any dict-like mapping class."""

    def _tidy(fn):
        setattr(fn, '_sa_instrumented', True)
        fn.__doc__ = getattr(getattr(dict, fn.__name__), '__doc__')

    Unspecified = util.symbol('Unspecified')

    def __setitem__(fn):
        def __setitem__(self, key, value, _sa_initiator=None):
            if key in self:
                __del(self, self[key], _sa_initiator)
            value = __set(self, value, _sa_initiator)
            fn(self, key, value)
        _tidy(__setitem__)
        return __setitem__

    def __delitem__(fn):
        def __delitem__(self, key, _sa_initiator=None):
            if key in self:
                __del(self, self[key], _sa_initiator)
            fn(self, key)
        _tidy(__delitem__)
        return __delitem__

    def clear(fn):
        def clear(self):
            for key in self:
                __del(self, self[key])
            fn(self)
        _tidy(clear)
        return clear

    def pop(fn):
        def pop(self, key, default=Unspecified):
            if key in self:
                __del(self, self[key])
            if default is Unspecified:
                return fn(self, key)
            else:
                return fn(self, key, default)
        _tidy(pop)
        return pop

    def popitem(fn):
        def popitem(self):
            __before_delete(self)
            item = fn(self)
            __del(self, item[1])
            return item
        _tidy(popitem)
        return popitem

    def setdefault(fn):
        def setdefault(self, key, default=None):
            if key not in self:
                self.__setitem__(key, default)
                return default
            else:
                return self.__getitem__(key)
        _tidy(setdefault)
        return setdefault

    if sys.version_info < (2, 4):
        def update(fn):
            def update(self, other):
                for key in other.keys():
                    if key not in self or self[key] is not other[key]:
                        self[key] = other[key]
            _tidy(update)
            return update
    else:
        def update(fn):
            def update(self, __other=Unspecified, **kw):
                if __other is not Unspecified:
                    if hasattr(__other, 'keys'):
                        for key in __other.keys():
                            if (key not in self or
                                self[key] is not __other[key]):
                                self[key] = __other[key]
                    else:
                        for key, value in __other:
                            if key not in self or self[key] is not value:
                                self[key] = value
                for key in kw:
                    if key not in self or self[key] is not kw[key]:
                        self[key] = kw[key]
            _tidy(update)
            return update

    l = locals().copy()
    l.pop('_tidy')
    l.pop('Unspecified')
    return l
开发者ID:AntonNguyen,项目名称:easy_api,代码行数:95,代码来源:collections.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.text_type函数代码示例发布时间:2022-05-27
下一篇:
Python util.importlater函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap