]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
import of "sqlalchemy" and "sqlalchemy.orm" works.
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Apr 2013 00:58:13 +0000 (20:58 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Apr 2013 00:58:13 +0000 (20:58 -0400)
09notes.txt
lib/sqlalchemy/engine/strategies.py
lib/sqlalchemy/engine/url.py
lib/sqlalchemy/event.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/functions.py
lib/sqlalchemy/sql/visitors.py

index 6b6295c4f1d51446d7ed5e943ef8a29588d16f8c..73652f96d01440abce1332550cddebf85fcffd36 100644 (file)
@@ -3,4 +3,8 @@
 
 - make sure input() function in dogpile example works in py2
 - we want to get rid of any support for sets.Set entirely; check to see what
-impact this has
+impact this has.   in langhelpers as well as in collections.py
+- give raise_from_cause some more manual tests:
+        - schema.py has one
+        - engine/strategies.py on connect
+        - sql/compiler.py for column errors in create table
\ No newline at end of file
index bed14c6718fa5f5eca40b04128ee85e4fe18fb48..c65986ca27cc4592ea449db4db666bc591f7477d 100644 (file)
@@ -80,19 +80,12 @@ class DefaultEngineStrategy(EngineStrategy):
                     return dialect.connect(*cargs, **cparams)
                 except Exception as e:
                     invalidated = dialect.is_disconnect(e, None, None)
-# start Py3K
-                    raise exc.DBAPIError.instance(None, None,
-                        e, dialect.dbapi.Error,
-                        connection_invalidated=invalidated
-                    ) from e
-# end Py3K
-# start Py2K
-#                    import sys
-#                    raise exc.DBAPIError.instance(
-#                        None, None, e, dialect.dbapi.Error,
-#                        connection_invalidated=invalidated
-#                    ), None, sys.exc_info()[2]
-# end Py2K
+                    util.raise_from_cause(
+                        exc.DBAPIError.instance(None, None,
+                            e, dialect.dbapi.Error,
+                            connection_invalidated=invalidated
+                        )
+                    )
 
             creator = kwargs.pop('creator', connect)
 
index 45768c5dc17bc4227afea87940ec36ba23f13651..b7d56374e7f96a554d45bc141a9271975b7965c6 100644 (file)
@@ -14,7 +14,6 @@ be used directly and is also accepted directly by ``create_engine()``.
 """
 
 import re
-import urllib.request, urllib.parse, urllib.error
 from .. import exc, util
 from . import Dialect
 
@@ -67,7 +66,7 @@ class URL(object):
         if self.username is not None:
             s += self.username
             if self.password is not None:
-                s += ':' + urllib.parse.quote_plus(self.password)
+                s += ':' + util.quote_plus(self.password)
             s += "@"
         if self.host is not None:
             s += self.host
@@ -76,7 +75,7 @@ class URL(object):
         if self.database is not None:
             s += '/' + self.database
         if self.query:
-            keys = list(self.query.keys())
+            keys = list(self.query)
             keys.sort()
             s += '?' + "&".join("%s=%s" % (k, self.query[k]) for k in keys)
         return s
@@ -177,17 +176,15 @@ def _parse_rfc1738_args(name):
             tokens = components['database'].split('?', 2)
             components['database'] = tokens[0]
             query = (len(tokens) > 1 and dict(util.parse_qsl(tokens[1]))) or None
-# start Py2K
-#            if query is not None:
-#                query = dict((k.encode('ascii'), query[k]) for k in query)
-# end Py2K
+            if util.py2k and query is not None:
+                query = dict((k.encode('ascii'), query[k]) for k in query)
         else:
             query = None
         components['query'] = query
 
         if components['password'] is not None:
             components['password'] = \
-                urllib.parse.unquote_plus(components['password'])
+                util.unquote_plus(components['password'])
 
         name = components.pop('name')
         return URL(name, **components)
index 316161fdf7196cfbef7c6734194af39e12deb6dd..79d024f9ba0218502d5f396674193dd2a6b00a9b 100644 (file)
@@ -171,7 +171,8 @@ class _EventMeta(type):
     associated _Dispatch classes."""
 
     def __init__(cls, classname, bases, dict_):
-        _create_dispatcher_class(cls, classname, bases, dict_)
+        if classname != 'MetaBase':
+            _create_dispatcher_class(cls, classname, bases, dict_)
         return type.__init__(cls, classname, bases, dict_)
 
 
@@ -200,11 +201,9 @@ def _remove_dispatcher(cls):
             if not _registrars[k]:
                 del _registrars[k]
 
-class Events(object): #util.with_metaclass(_EventMeta, object)):
+class Events(util.with_metaclass(_EventMeta, object)):
     """Define event listening functions for a particular target type."""
 
-    __metaclass__ = _EventMeta
-
     @classmethod
     def _accept_with(cls, target):
         # Mapper, ClassManager, Session override this to
index 0a11b83c6d43862e05715183acc1f87f99e6ed8d..c2a2c23f0dcbb0892f02f5ac5285abae7493c169 100644 (file)
@@ -1272,11 +1272,7 @@ def _dict_decorators():
     l.pop('Unspecified')
     return l
 
-if util.py3k_warning:
-    _set_binop_bases = (set, frozenset)
-else:
-    import sets
-    _set_binop_bases = (set, frozenset, sets.BaseSet)
+_set_binop_bases = (set, frozenset)
 
 
 def _set_binops_check_strict(self, obj):
index f14c8ca47f9e87f397edaeba65aa0c000e508dbb..a814044018f226a49d00566b60389ccdf96c623a 100644 (file)
@@ -16,6 +16,7 @@ classes within should be considered mostly private.
 
 """
 
+from __future__ import absolute_import
 
 from .. import exc as sa_exc, util, inspect
 from ..sql import operators
index 91c6785470a2ebfe9909b8995ea381d296a154ad..645bf86e7020af42d46c6e353689a899484d2a7a 100644 (file)
@@ -13,6 +13,7 @@ This is a semi-private module; the main configurational API of the ORM is
 available in :class:`~sqlalchemy.orm.`.
 
 """
+from __future__ import absolute_import
 
 import types
 import weakref
@@ -26,8 +27,8 @@ from . import instrumentation, attributes, \
 from .interfaces import MapperProperty, _InspectionAttr, _MappedAttribute
 
 from .util import _INSTRUMENTOR, _class_to_mapper, \
-     _state_mapper, class_mapper, \
-     PathRegistry
+        _state_mapper, class_mapper, \
+        PathRegistry
 import sys
 properties = util.importlater("sqlalchemy.orm", "properties")
 descriptor_props = util.importlater("sqlalchemy.orm", "descriptor_props")
index e5a2da36625092bcd1297266515b9707e82ff87c..b3f74ceefc0cf31082dac4a67815763ec5f1c073 100644 (file)
@@ -1869,22 +1869,12 @@ class DDLCompiler(engine.Compiled):
                 if column.primary_key:
                     first_pk = True
             except exc.CompileError as ce:
-# start Py3K
-                raise exc.CompileError("(in table '%s', column '%s'): %s"
-                                             % (
+                util.raise_from_cause(
+                    exc.CompileError("(in table '%s', column '%s'): %s" % (
                                                 table.description,
                                                 column.name,
                                                 ce.args[0]
-                                            )) from ce
-# end Py3K
-# start Py2K
-#                raise exc.CompileError("(in table '%s', column '%s'): %s"
-#                                            % (
-#                                                table.description,
-#                                                column.name,
-#                                                ce.args[0]
-#                                            )), None, sys.exc_info()[2]
-# end Py2K
+                                            )))
 
         const = self.create_table_constraints(table)
         if const:
index a2b7ac628af8488148e20f2d39ef2588fee940ce..244505bed104cef046fa5eda47142beaa4f23809 100644 (file)
@@ -31,17 +31,18 @@ def register_function(identifier, fn, package="_default"):
 
 class _GenericMeta(VisitableType):
     def __init__(cls, clsname, bases, clsdict):
-        cls.name = name = clsdict.get('name', clsname)
-        cls.identifier = identifier = clsdict.get('identifier', name)
-        package = clsdict.pop('package', '_default')
-        # legacy
-        if '__return_type__' in clsdict:
-            cls.type = clsdict['__return_type__']
-        register_function(identifier, cls, package)
+        if clsname != 'MetaBase':
+            cls.name = name = clsdict.get('name', clsname)
+            cls.identifier = identifier = clsdict.get('identifier', name)
+            package = clsdict.pop('package', '_default')
+            # legacy
+            if '__return_type__' in clsdict:
+                cls.type = clsdict['__return_type__']
+            register_function(identifier, cls, package)
         super(_GenericMeta, cls).__init__(clsname, bases, clsdict)
 
 
-class GenericFunction(Function, metaclass=_GenericMeta):
+class GenericFunction(util.with_metaclass(_GenericMeta, Function)):
     """Define a 'generic' function.
 
     A generic function is a pre-established :class:`.Function`
index 6efce504a76bbb77fad59465bf06252bf6b7b890..4d294846280e8be818b566de09a5121ad96fab68 100644 (file)
@@ -49,11 +49,9 @@ class VisitableType(type):
     Classes having no __visit_name__ attribute will remain unaffected.
     """
     def __init__(cls, clsname, bases, clsdict):
-        if cls.__name__ == 'Visitable' or not hasattr(cls, '__visit_name__'):
-            super(VisitableType, cls).__init__(clsname, bases, clsdict)
-            return
-
-        _generate_dispatch(cls)
+        if clsname not in ('MetaBase', 'Visitable') and \
+                hasattr(cls, '__visit_name__'):
+            _generate_dispatch(cls)
 
         super(VisitableType, cls).__init__(clsname, bases, clsdict)