From: Mike Bayer Date: Fri, 3 Jul 2009 18:42:41 +0000 (+0000) Subject: fixed a nasty import hack and removed AbstractType.get_search_list(). X-Git-Tag: rel_0_6_6~155 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0caf5f48b76f4cc6cb60c0bfbd1c858e6688ed5d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fixed a nasty import hack and removed AbstractType.get_search_list(). --- diff --git a/06CHANGES b/06CHANGES index 13b233fc8f..a726ec22aa 100644 --- a/06CHANGES +++ b/06CHANGES @@ -106,4 +106,8 @@ of mutable=True) if __eq__() is not overridden or a comparison function is not provided. - The default "precision" and "scale" arguments of Numeric and Float have been removed and now default to None. NUMERIC and FLOAT will be rendered with no numeric arguments - by default unless these values are provided. \ No newline at end of file + by default unless these values are provided. + - AbstractType.get_search_list() is removed - the games that was used for are no + longer necessary. + + \ No newline at end of file diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py index 1b1b968557..31469ee5ae 100644 --- a/lib/sqlalchemy/__init__.py +++ b/lib/sqlalchemy/__init__.py @@ -10,42 +10,6 @@ import sys import sqlalchemy.exc as exceptions sys.modules['sqlalchemy.exceptions'] = exceptions -from sqlalchemy.types import ( - BLOB, - BOOLEAN, - Binary, - Boolean, - CHAR, - CLOB, - DATE, - DATETIME, - DECIMAL, - Date, - DateTime, - FLOAT, - Float, - INT, - INTEGER, - Integer, - Interval, - NCHAR, - NVARCHAR, - NUMERIC, - Numeric, - PickleType, - SMALLINT, - SmallInteger, - String, - TEXT, - TIME, - TIMESTAMP, - Text, - Time, - Unicode, - UnicodeText, - VARCHAR, - ) - from sqlalchemy.sql import ( alias, and_, @@ -83,6 +47,43 @@ from sqlalchemy.sql import ( update, ) +from sqlalchemy.types import ( + BLOB, + BOOLEAN, + Binary, + Boolean, + CHAR, + CLOB, + DATE, + DATETIME, + DECIMAL, + Date, + DateTime, + FLOAT, + Float, + INT, + INTEGER, + Integer, + Interval, + NCHAR, + NVARCHAR, + NUMERIC, + Numeric, + PickleType, + SMALLINT, + SmallInteger, + String, + TEXT, + TIME, + TIMESTAMP, + Text, + Time, + Unicode, + UnicodeText, + VARCHAR, + ) + + from sqlalchemy.schema import ( CheckConstraint, Column, diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index fb5662bd12..60d80e811b 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -157,6 +157,7 @@ colspecs = { sqltypes.Text : OracleText, sqltypes.UnicodeText : OracleUnicodeText, sqltypes.TIMESTAMP : OracleTimestamp, + OracleRaw: cxOracleRaw, } class Oracle_cx_oracleExecutionContext(DefaultExecutionContext): diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 3d212df7a3..519c2cacc3 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -29,12 +29,12 @@ to stay the same in future releases. import itertools, re from operator import attrgetter -from sqlalchemy import util, exc +from sqlalchemy import util, exc, types as sqltypes from sqlalchemy.sql import operators from sqlalchemy.sql.visitors import Visitable, cloned_traverse import operator -functions, schema, sql_util, sqltypes = None, None, None, None +functions, schema, sql_util = None, None, None DefaultDialect, ClauseAdapter, Annotated = None, None, None __all__ = [ diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 5162cc53b5..ff7e466782 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -28,9 +28,6 @@ from decimal import Decimal as _python_Decimal from sqlalchemy import exc from sqlalchemy.util import pickle from sqlalchemy.sql.visitors import Visitable -from sqlalchemy.sql import expression -import sys -expression.sqltypes = sys.modules[__name__] import sqlalchemy.util as util NoneType = type(None) @@ -89,14 +86,6 @@ class AbstractType(Visitable): """ return op - def get_search_list(self): - """return a list of classes to test for a match - when adapting this type to a dialect-specific type. - - """ - - return self.__class__.__mro__[0:-1] - def __repr__(self): return "%s(%s)" % ( self.__class__.__name__, @@ -106,18 +95,19 @@ class AbstractType(Visitable): class TypeEngine(AbstractType): """Base for built-in types.""" + @util.memoized_property + def _impl_dict(self): + return {} + def dialect_impl(self, dialect, **kwargs): try: return self._impl_dict[dialect.__class__] - except AttributeError: - self._impl_dict = {} - return self._impl_dict.setdefault(dialect.__class__, dialect.__class__.type_descriptor(self)) except KeyError: return self._impl_dict.setdefault(dialect.__class__, dialect.__class__.type_descriptor(self)) def __getstate__(self): d = self.__dict__.copy() - d['_impl_dict'] = {} + d.pop('_impl_dict', None) return d def bind_processor(self, dialect): @@ -227,7 +217,8 @@ class TypeDecorator(AbstractType): def __init__(self, *args, **kwargs): if not hasattr(self.__class__, 'impl'): - raise AssertionError("TypeDecorator implementations require a class-level variable 'impl' which refers to the class of type being decorated") + raise AssertionError("TypeDecorator implementations require a class-level " + "variable 'impl' which refers to the class of type being decorated") self.impl = self.__class__.impl(*args, **kwargs) def dialect_impl(self, dialect): @@ -365,7 +356,7 @@ def to_instance(typeobj): def adapt_type(typeobj, colspecs): if isinstance(typeobj, type): typeobj = typeobj() - for t in typeobj.get_search_list(): + for t in typeobj.__class__.__mro__[0:-1]: try: impltype = colspecs[t] break