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


Python util.symbol函数代码示例

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


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


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