Commits

Mike Bayer committed 92a08c9

- remove some remaining sys.modules shenanigans
- The "sqlalchemy.exceptions" alias in sys.modules
has been removed. Base SQLA exceptions are
available via "from sqlalchemy import exc".
The "exceptions" alias for "exc" remains in
"sqlalchemy" for now, it's just not patched into
sys.modules.

Comments (0)

Files changed (15)

   - Setup no longer installs a Nose plugin
     [ticket:1949]
 
+  - The "sqlalchemy.exceptions" alias in sys.modules
+    has been removed.   Base SQLA exceptions are 
+    available via "from sqlalchemy import exc".
+    The "exceptions" alias for "exc" remains in 
+    "sqlalchemy" for now, it's just not patched into 
+    sys.modules.
+
 - orm
   - More succinct form of query.join(target, onclause)
     [ticket:1923]

lib/sqlalchemy/__init__.py

 import sys
 
 import sqlalchemy.exc as exceptions
-sys.modules['sqlalchemy.exceptions'] = exceptions
 
 from sqlalchemy.sql import (
     alias,

lib/sqlalchemy/ext/horizontal_shard.py

 
 """
 
-import sqlalchemy.exceptions as sa_exc
+from sqlalchemy import exc as sa_exc
 from sqlalchemy import util
 from sqlalchemy.orm.session import Session
 from sqlalchemy.orm.query import Query

lib/sqlalchemy/ext/sqlsoup.py

                             class_mapper, relationship, session,\
                             object_session, attributes
 from sqlalchemy.orm.interfaces import MapperExtension, EXT_CONTINUE
-from sqlalchemy.exceptions import SQLAlchemyError, InvalidRequestError, ArgumentError
+from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, ArgumentError
 from sqlalchemy.sql import expression
 
 

lib/sqlalchemy/orm/attributes.py

 import operator
 from operator import itemgetter
 
-from sqlalchemy import util, event
+from sqlalchemy import util, event, exc as sa_exc
 from sqlalchemy.orm import interfaces, collections, events
-import sqlalchemy.exceptions as sa_exc
+
 
 mapperutil = util.importlater("sqlalchemy.orm", "util")
 

lib/sqlalchemy/orm/collections.py

 import sys
 import weakref
 
-import sqlalchemy.exceptions as sa_exc
 from sqlalchemy.sql import expression
-from sqlalchemy import schema, util
+from sqlalchemy import schema, util, exc as sa_exc
 
 
 __all__ = ['collection', 'collection_adapter',

lib/sqlalchemy/orm/dependency.py

 
 """
 
-from sqlalchemy import sql, util
-import sqlalchemy.exceptions as sa_exc
+from sqlalchemy import sql, util, exc as sa_exc
 from sqlalchemy.orm import attributes, exc, sync, unitofwork, \
                                         util as mapperutil
 from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE, MANYTOMANY

lib/sqlalchemy/orm/interfaces.py

 
 from itertools import chain
 
-import sqlalchemy.exceptions as sa_exc
+from sqlalchemy import exc as sa_exc
 from sqlalchemy import log, util, event
 from sqlalchemy.sql import expression
 deque = util.importlater('collections').deque

lib/sqlalchemy/orm/properties.py

 
 """
 
-from sqlalchemy import sql, util, log
-import sqlalchemy.exceptions as sa_exc
+from sqlalchemy import sql, util, log, exc as sa_exc
 from sqlalchemy.sql.util import ClauseAdapter, criterion_as_pairs, \
     join_condition
 from sqlalchemy.sql import operators, expression

lib/sqlalchemy/orm/scoping.py

 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-import sqlalchemy.exceptions as sa_exc
+from sqlalchemy import exc as sa_exc
 from sqlalchemy.util import ScopedRegistry, ThreadLocalRegistry, warn
 from sqlalchemy.orm import class_mapper
 from sqlalchemy.orm import exc as orm_exc

lib/sqlalchemy/orm/session.py

 
 import weakref
 from itertools import chain
-import sqlalchemy.exceptions as sa_exc
-from sqlalchemy import util, sql, engine, log
+from sqlalchemy import util, sql, engine, log, exc as sa_exc
 from sqlalchemy.sql import util as sql_util, expression
 from sqlalchemy.orm import (
     SessionExtension, attributes, exc, query, unitofwork, util as mapperutil, state

lib/sqlalchemy/orm/util.py

 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-import sqlalchemy.exceptions as sa_exc
-from sqlalchemy import sql, util, event
+
+from sqlalchemy import sql, util, event, exc as sa_exc
 from sqlalchemy.sql import expression, util as sql_util, operators
 from sqlalchemy.orm.interfaces import MapperExtension, EXT_CONTINUE,\
                                 PropComparator, MapperProperty

lib/sqlalchemy/schema.py

 
 sqlutil = util.importlater("sqlalchemy.sql", "util")
 url = util.importlater("sqlalchemy.engine", "url")
-
+sqltypes = util.importlater("sqlalchemy", "types")
 
 __all__ = ['SchemaItem', 'Table', 'Column', 'ForeignKey', 'Sequence', 'Index',
            'ForeignKeyConstraint', 'PrimaryKeyConstraint', 'CheckConstraint',
     def _autoincrement_column(self):
         for col in self.primary_key:
             if col.autoincrement and \
-                issubclass(col.type._type_affinity, types.Integer) and \
+                issubclass(col.type._type_affinity, sqltypes.Integer) and \
                 not col.foreign_keys and \
                 isinstance(col.default, (type(None), Sequence)) and \
                 (col.server_default is None or col.server_default.reflected):
         if args:
             coltype = args[0]
 
-            if (isinstance(coltype, types.TypeEngine) or
+            if (isinstance(coltype, sqltypes.TypeEngine) or
                 (isinstance(coltype, type) and
-                 issubclass(coltype, types.TypeEngine))):
+                 issubclass(coltype, sqltypes.TypeEngine))):
                 if type_ is not None:
                     raise exc.ArgumentError(
                         "May not pass type_ positionally and as a keyword.")
         if '_proxies' in kwargs:
             self.proxies = kwargs.pop('_proxies')
         # otherwise, add DDL-related events
-        elif isinstance(self.type, types.SchemaType):
+        elif isinstance(self.type, sqltypes.SchemaType):
             self.type._set_parent_with_dispatch(self)
 
         if self.default is not None:
             _column = self._colspec
 
         # propagate TypeEngine to parent if it didn't have one
-        if isinstance(self.parent.type, types.NullType):
+        if isinstance(self.parent.type, sqltypes.NullType):
             self.parent.type = _column.type
         return _column
 

lib/sqlalchemy/types.py

 
 from sqlalchemy import exc, schema
 from sqlalchemy.sql import expression, operators
-import sys
-schema.types = expression.sqltypes = sys.modules['sqlalchemy.types']
 from sqlalchemy.util import pickle
 from sqlalchemy.util.compat import decimal
 from sqlalchemy.sql.visitors import Visitable

test/orm/_base.py

 import sys
 import types
 import sqlalchemy as sa
-import sqlalchemy.exceptions as sa_exc
+from sqlalchemy import exc as sa_exc
 from test.lib import config, testing
 from test.lib.testing import resolve_artifact_names, adict
 from test.lib.engines import drop_all_tables
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.