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

Python util.warn_deprecated函数代码示例

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

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



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

示例1: visit_create_index

 def visit_create_index(self, create):
     preparer = self.preparer
     index = create.element
     text = "CREATE "
     if index.unique:
         text += "UNIQUE "
     text += "INDEX %s ON %s (%s)" \
                 % (preparer.quote(self._validate_identifier(index.name, True), index.quote),
                    preparer.format_table(index.table),
                    ', '.join([preparer.format_column(c) for c in index.columns]))
     
     if "postgres_where" in index.kwargs:
         whereclause = index.kwargs['postgres_where']
         util.warn_deprecated("The 'postgres_where' argument has been renamed to 'postgresql_where'.")
     elif 'postgresql_where' in index.kwargs:
         whereclause = index.kwargs['postgresql_where']
     else:
         whereclause = None
         
     if whereclause is not None:
         compiler = self._compile(whereclause, None)
         # this might belong to the compiler class
         inlined_clause = str(compiler) % dict(
             [(key,bind.value) for key,bind in compiler.binds.iteritems()])
         text += " WHERE " + inlined_clause
     return text
开发者ID:dreamwave,项目名称:rad,代码行数:26,代码来源:base.py


示例2: visit_create_index

 def visit_create_index(self, create):
     preparer = self.preparer
     index = create.element
     text = "CREATE "
     if index.unique:
         text += "UNIQUE "
     text += "INDEX %s ON %s (%s)" \
             % (preparer.quote(
                 self._validate_identifier(index.name, True), index.quote),
                preparer.format_table(index.table),
                ', '.join([preparer.format_column(c) 
                             for c in index.columns]))
     
     if "postgres_where" in index.kwargs:
         whereclause = index.kwargs['postgres_where']
         util.warn_deprecated(
                 "The 'postgres_where' argument has been renamed "
                 "to 'postgresql_where'.")
     elif 'postgresql_where' in index.kwargs:
         whereclause = index.kwargs['postgresql_where']
     else:
         whereclause = None
         
     if whereclause is not None:
         whereclause = sql_util.expression_as_ddl(whereclause)
         where_compiled = self.sql_compiler.process(whereclause)
         text += " WHERE " + where_compiled
     return text
开发者ID:advatar,项目名称:thevault,代码行数:28,代码来源:base.py


示例3: dbapi

    def dbapi(cls):

        warn_deprecated(
            "Google Cloud SQL now recommends creating connections via the "
            "MySQLdb dialect directly, using the URL format "
            "mysql+mysqldb://[email protected]/<dbname>?unix_socket=/cloudsql/"
            "<projectid>:<instancename>"
        )

        # from django:
        # http://code.google.com/p/googleappengine/source/
        #     browse/trunk/python/google/storage/speckle/
        # python/django/backend/base.py#118
        # see also [ticket:2649]
        # see also http://stackoverflow.com/q/14224679/34549
        from google.appengine.api import apiproxy_stub_map

        if _is_dev_environment():
            from google.appengine.api import rdbms_mysqldb
            return rdbms_mysqldb
        elif apiproxy_stub_map.apiproxy.GetStub('rdbms'):
            from google.storage.speckle.python.api import rdbms_apiproxy
            return rdbms_apiproxy
        else:
            from google.storage.speckle.python.api import rdbms_googleapi
            return rdbms_googleapi
开发者ID:mickmccauley,项目名称:sensorcis,代码行数:26,代码来源:gaerdbms.py


示例4: get_history

def get_history(obj, key, passive=PASSIVE_OFF):
    """Return a :class:`.History` record for the given object 
    and attribute key.

    :param obj: an object whose class is instrumented by the
      attributes package.

    :param key: string attribute name.

    :param passive: indicates if the attribute should be
      loaded from the database if not already present (:attr:`.PASSIVE_NO_FETCH`), and
      if the attribute should be not initialized to a blank value otherwise
      (:attr:`.PASSIVE_NO_INITIALIZE`). Default is :attr:`PASSIVE_OFF`.

    """
    if passive is True:
        util.warn_deprecated("Passing True for 'passive' is deprecated. "
                                "Use attributes.PASSIVE_NO_INITIALIZE")
        passive = PASSIVE_NO_INITIALIZE
    elif passive is False:
        util.warn_deprecated("Passing False for 'passive' is "
                                "deprecated.  Use attributes.PASSIVE_OFF")
        passive = PASSIVE_OFF

    return get_state_history(instance_state(obj), key, passive)
开发者ID:MorganBorman,项目名称:cxsbs,代码行数:25,代码来源:attributes.py


示例5: compare_values

 def compare_values(self, x, y):
     if self.comparator:
         return self.comparator(x, y)
     elif self.mutable and not hasattr(x, '__eq__') and x is not None:
         util.warn_deprecated("Objects stored with PickleType when mutable=True must implement __eq__() for reliable comparison.")
         return self.pickler.dumps(x, self.protocol) == self.pickler.dumps(y, self.protocol)
     else:
         return x == y
开发者ID:openplans,项目名称:geowebdns-lib,代码行数:8,代码来源:types.py


示例6: dialect_impl

 def dialect_impl(self, dialect, **kwargs):
     _for_ddl = kwargs.pop("_for_ddl", False)
     if _for_ddl and self.length is None:
         label = util.to_ascii(_for_ddl is True and "" or (' for column "%s"' % str(_for_ddl)))
         util.warn_deprecated(
             "Using String type with no length for CREATE TABLE "
             "is deprecated; use the Text type explicitly" + label
         )
     return TypeEngine.dialect_impl(self, dialect, **kwargs)
开发者ID:HollowEarthRadio,项目名称:chirpradio-volunteers,代码行数:9,代码来源:types.py


示例7: __init__

    def __init__(
        self,
        convert_unicode=False,
        assert_unicode=False,
        encoding="utf-8",
        paramstyle=None,
        dbapi=None,
        implicit_returning=None,
        label_length=None,
        **kwargs
    ):

        if not getattr(self, "ported_sqla_06", True):
            util.warn("The %s dialect is not yet ported to SQLAlchemy 0.6/0.7" % self.name)

        self.convert_unicode = convert_unicode
        if assert_unicode:
            util.warn_deprecated(
                "assert_unicode is deprecated. "
                "SQLAlchemy emits a warning in all cases where it "
                "would otherwise like to encode a Python unicode object "
                "into a specific encoding but a plain bytestring is "
                "received. "
                "This does *not* apply to DBAPIs that coerce Unicode "
                "natively."
            )

        self.encoding = encoding
        self.positional = False
        self._ischema = None
        self.dbapi = dbapi
        if paramstyle is not None:
            self.paramstyle = paramstyle
        elif self.dbapi is not None:
            self.paramstyle = self.dbapi.paramstyle
        else:
            self.paramstyle = self.default_paramstyle
        if implicit_returning is not None:
            self.implicit_returning = implicit_returning
        self.positional = self.paramstyle in ("qmark", "format", "numeric")
        self.identifier_preparer = self.preparer(self)
        self.type_compiler = self.type_compiler(self)

        if label_length and label_length > self.max_identifier_length:
            raise exc.ArgumentError(
                "Label length of %d is greater than this dialect's"
                " maximum identifier length of %d" % (label_length, self.max_identifier_length)
            )
        self.label_length = label_length

        if self.description_encoding == "use_encoding":
            self._description_decoder = processors.to_unicode_processor_factory(encoding)
        elif self.description_encoding is not None:
            self._description_decoder = processors.to_unicode_processor_factory(self.description_encoding)
        self._encoder = codecs.getencoder(self.encoding)
        self._decoder = processors.to_unicode_processor_factory(self.encoding)
开发者ID:neonrush,项目名称:CouchPotatoServer,代码行数:56,代码来源:default.py


示例8: __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


示例9: _pop_deprecated_kwargs

 def _pop_deprecated_kwargs(self, kwargs):
     auto_setinputsizes = kwargs.pop('auto_setinputsizes', None)
     exclude_setinputsizes = kwargs.pop('exclude_setinputsizes', None)
     if auto_setinputsizes or exclude_setinputsizes:
         util.warn_deprecated(
             "auto_setinputsizes and exclude_setinputsizes are deprecated. "
             "Modern cx_Oracle only requires that LOB types are part "
             "of this behavior, and these parameters no longer have any "
             "effect.")
     allow_twophase = kwargs.pop('allow_twophase', None)
     if allow_twophase is not None:
         util.warn.deprecated(
             "allow_twophase is deprecated.  The cx_Oracle dialect no "
             "longer supports two-phase transaction mode."
         )
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:15,代码来源:cx_oracle.py


示例10: __init__

    def __init__(self, precision=10, scale=2, asdecimal=True, length=None):
        """
        Construct a Numeric.

        :param precision: the numeric precision for use in DDL ``CREATE TABLE``.

        :param scale: the numeric scale for use in DDL ``CREATE TABLE``.

        :param asdecimal: default True.  If False, values will be
          returned as-is from the DB-API, and may be either
          ``Decimal`` or ``float`` types depending on the DB-API in
          use.

        """
        if length:
            util.warn_deprecated("'length' is deprecated for Numeric.  Use 'scale'.")
            scale = length
        self.precision = precision
        self.scale = scale
        self.asdecimal = asdecimal
开发者ID:openplans,项目名称:geowebdns-lib,代码行数:20,代码来源:types.py


示例11: create_session

def create_session(bind=None, **kwargs):
    """Create a new :class:`~sqlalchemy.orm.session.Session`.

    :param bind: optional, a single Connectable to use for all
      database access in the created
      :class:`~sqlalchemy.orm.session.Session`.

    :param \*\*kwargs: optional, passed through to the
      :class:`Session` constructor.

    :returns: an :class:`~sqlalchemy.orm.session.Session` instance

    The defaults of create_session() are the opposite of that of
    :func:`sessionmaker`; ``autoflush`` and ``expire_on_commit`` are
    False, ``autocommit`` is True.  In this sense the session acts
    more like the "classic" SQLAlchemy 0.3 session with these.

    Usage::

      >>> from sqlalchemy.orm import create_session
      >>> session = create_session()

    It is recommended to use :func:`sessionmaker` instead of
    create_session().

    """
    if 'transactional' in kwargs:
        sa_util.warn_deprecated(
            "The 'transactional' argument to sessionmaker() is deprecated; "
            "use autocommit=True|False instead.")
        if 'autocommit' in kwargs:
            raise TypeError('Specify autocommit *or* transactional, not both.')
        kwargs['autocommit'] = not kwargs.pop('transactional')

    kwargs.setdefault('autoflush', False)
    kwargs.setdefault('autocommit', True)
    kwargs.setdefault('expire_on_commit', False)
    return _Session(bind=bind, **kwargs)
开发者ID:greghaynes,项目名称:xsbs,代码行数:38,代码来源:__init__.py


示例12: __init__

    def __init__(self,
                    creator, recycle=-1, echo=None,
                    use_threadlocal=False,
                    logging_name=None,
                    reset_on_return=True,
                    listeners=None,
                    events=None,
                    _dispatch=None):
        """
        Construct a Pool.

        :param creator: a callable function that returns a DB-API
          connection object.  The function will be called with
          parameters.

        :param recycle: If set to non -1, number of seconds between
          connection recycling, which means upon checkout, if this
          timeout is surpassed the connection will be closed and
          replaced with a newly opened connection. Defaults to -1.

        :param logging_name:  String identifier which will be used within
          the "name" field of logging records generated within the
          "sqlalchemy.pool" logger. Defaults to a hexstring of the object's
          id.

        :param echo: If True, connections being pulled and retrieved
          from the pool will be logged to the standard output, as well
          as pool sizing information.  Echoing can also be achieved by
          enabling logging for the "sqlalchemy.pool"
          namespace. Defaults to False.

        :param use_threadlocal: If set to True, repeated calls to
          :meth:`connect` within the same application thread will be
          guaranteed to return the same connection object, if one has
          already been retrieved from the pool and has not been
          returned yet.  Offers a slight performance advantage at the
          cost of individual transactions by default.  The
          :meth:`unique_connection` method is provided to bypass the
          threadlocal behavior installed into :meth:`connect`.

        :param reset_on_return: If true, reset the database state of
          connections returned to the pool.  This is typically a
          ROLLBACK to release locks and transaction resources.
          Disable at your own peril.  Defaults to True.

        :param events: a list of 2-tuples, each of the form
         ``(callable, target)`` which will be passed to event.listen()
         upon construction.   Provided here so that event listeners
         can be assigned via ``create_engine`` before dialect-level
         listeners are applied.

        :param listeners: Deprecated.  A list of
          :class:`~sqlalchemy.interfaces.PoolListener`-like objects or
          dictionaries of callables that receive events when DB-API
          connections are created, checked out and checked in to the
          pool.  This has been superseded by
          :func:`~sqlalchemy.event.listen`.

        """
        if logging_name:
            self.logging_name = self._orig_logging_name = logging_name
        else:
            self._orig_logging_name = None

        log.instance_logger(self, echoflag=echo)
        self._threadconns = threading.local()
        self._creator = creator
        self._recycle = recycle
        self._use_threadlocal = use_threadlocal
        if reset_on_return in ('rollback', True, reset_rollback):
            self._reset_on_return = reset_rollback
        elif reset_on_return in (None, False, reset_none):
            self._reset_on_return = reset_none
        elif reset_on_return in ('commit', reset_commit):
            self._reset_on_return = reset_commit
        else:
            raise exc.ArgumentError(
                        "Invalid value for 'reset_on_return': %r"
                                    % reset_on_return)

        self.echo = echo
        if _dispatch:
            self.dispatch._update(_dispatch, only_propagate=False)
        if events:
            for fn, target in events:
                event.listen(self, target, fn)
        if listeners:
            util.warn_deprecated(
                        "The 'listeners' argument to Pool (and "
                        "create_engine()) is deprecated.  Use event.listen().")
            for l in listeners:
                self.add_listener(l)
开发者ID:y2bishop2y,项目名称:microengine,代码行数:92,代码来源:pool.py


示例13: __init__

 def __init__(self, *args, **kwargs):
     warn_deprecated("SessionContextExt is deprecated.  Use ScopedSession(enhance_classes=True)")
     super(SessionContextExt, self).__init__(*args, **kwargs)
开发者ID:Eubolist,项目名称:ankimini,代码行数:3,代码来源:sessioncontext.py


示例14: warn_deprecated

# backwards compat with the old name
from sqlalchemy.util import warn_deprecated

warn_deprecated(
    "The SQLAlchemy PostgreSQL dialect has been renamed from 'postgres' to 'postgresql'. "
    "The new URL format is postgresql[+driver]://<user>:<pass>@<host>/<dbname>"
    )
    
from sqlalchemy.dialects.postgresql import *
from sqlalchemy.dialects.postgresql import base
开发者ID:Amelandbor,项目名称:CouchPotato,代码行数:10,代码来源:postgres.py


示例15: Copyright

# orm/shard.py
# Copyright (C) 2005-2011 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

from sqlalchemy import util

util.warn_deprecated(
    "Horizontal sharding is now importable via "
    "'import sqlalchemy.ext.horizontal_shard"
)

from sqlalchemy.ext.horizontal_shard import *

开发者ID:AntonNguyen,项目名称:easy_api,代码行数:14,代码来源:shard.py


示例16: do

 def do(self, *args, **kwargs):
     query = Query(class_, session=ctx.current)
     util.warn_deprecated('Query methods on the class are deprecated; use %s.query.%s instead' % (class_.__name__, name))
     return getattr(query, name)(*args, **kwargs)
开发者ID:Eubolist,项目名称:ankimini,代码行数:4,代码来源:assignmapper.py


示例17: __init__

    def __init__(self, argument, secondary=None, primaryjoin=None, secondaryjoin=None, entity_name=None, foreign_keys=None, foreignkey=None, uselist=None, private=False, association=None, order_by=False, attributeext=None, backref=None, is_backref=False, post_update=False, cascade=None, viewonly=False, lazy=True, collection_class=None, passive_deletes=False, passive_updates=True, remote_side=None, enable_typechecks=True, join_depth=None, strategy_class=None, _local_remote_pairs=None):
        self.uselist = uselist
        self.argument = argument
        self.entity_name = entity_name
        self.secondary = secondary
        self.primaryjoin = primaryjoin
        self.secondaryjoin = secondaryjoin
        self.post_update = post_update
        self.direction = None
        self.viewonly = viewonly
        self.lazy = lazy
        self.foreign_keys = util.to_set(foreign_keys)
        self._legacy_foreignkey = util.to_set(foreignkey)
        if foreignkey:
            util.warn_deprecated('foreignkey option is deprecated; see docs for details')
        self.collection_class = collection_class
        self.passive_deletes = passive_deletes
        self.passive_updates = passive_updates
        self.remote_side = util.to_set(remote_side)
        self.enable_typechecks = enable_typechecks
        self.comparator = PropertyLoader.Comparator(self)
        self.join_depth = join_depth
        self._arg_local_remote_pairs = _local_remote_pairs
        util.set_creation_order(self)
        
        if strategy_class:
            self.strategy_class = strategy_class
        elif self.lazy == 'dynamic':
            from sqlalchemy.orm import dynamic
            self.strategy_class = dynamic.DynaLoader
        elif self.lazy is False:
            self.strategy_class = strategies.EagerLoader
        elif self.lazy is None:
            self.strategy_class = strategies.NoLoader
        else:
            self.strategy_class = strategies.LazyLoader

        self._reverse_property = None
        
        if cascade is not None:
            self.cascade = CascadeOptions(cascade)
        else:
            if private:
                util.warn_deprecated('private option is deprecated; see docs for details')
                self.cascade = CascadeOptions("all, delete-orphan")
            else:
                self.cascade = CascadeOptions("save-update, merge")

        if self.passive_deletes == 'all' and ("delete" in self.cascade or "delete-orphan" in self.cascade):
            raise exceptions.ArgumentError("Can't set passive_deletes='all' in conjunction with 'delete' or 'delete-orphan' cascade")

        self.association = association
        if association:
            util.warn_deprecated('association option is deprecated; see docs for details')
        self.order_by = order_by
        self.attributeext=attributeext
        if isinstance(backref, str):
            # propigate explicitly sent primary/secondary join conditions to the BackRef object if
            # just a string was sent
            if secondary is not None:
                # reverse primary/secondary in case of a many-to-many
                self.backref = BackRef(backref, primaryjoin=secondaryjoin, secondaryjoin=primaryjoin, passive_updates=self.passive_updates)
            else:
                self.backref = BackRef(backref, primaryjoin=primaryjoin, secondaryjoin=secondaryjoin, passive_updates=self.passive_updates)
        else:
            self.backref = backref
        self.is_backref = is_backref
开发者ID:Eubolist,项目名称:ankimini,代码行数:67,代码来源:properties.py


示例18: MetaData

"""
information schema implementation.

This module is deprecated and will not be present in this form in SQLAlchemy 0.6.

"""
from sqlalchemy import util

util.warn_deprecated("the information_schema module is deprecated.")

import sqlalchemy.sql as sql
import sqlalchemy.exc as exc
from sqlalchemy import select, MetaData, Table, Column, String, Integer
from sqlalchemy.schema import DefaultClause, ForeignKeyConstraint

ischema = MetaData()

schemata = Table("schemata", ischema,
    Column("catalog_name", String),
    Column("schema_name", String),
    Column("schema_owner", String),
    schema="information_schema")

tables = Table("tables", ischema,
    Column("table_catalog", String),
    Column("table_schema", String),
    Column("table_name", String),
    Column("table_type", String),
    schema="information_schema")

columns = Table("columns", ischema,
开发者ID:GunioRobot,项目名称:xsbs,代码行数:31,代码来源:information_schema.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.OrderedDict类代码示例发布时间:2022-05-27
下一篇:
Python util.warn函数代码示例发布时间: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