]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- py3k stuff
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 30 May 2009 16:22:53 +0000 (16:22 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 30 May 2009 16:22:53 +0000 (16:22 +0000)
- we don't need column_dict in construct_params now

lib/sqlalchemy/ext/sqlsoup.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/sql/compiler.py
test/base/utils.py
test/zblog/user.py

index b3f2de743ef5c94e91b2162a1920c9eca0f97e21..d7f8619c55656f86c8cd3daf3de41335e20138c0 100644 (file)
@@ -447,9 +447,11 @@ def _selectable_name(selectable):
 def class_for_table(selectable, **mapper_kwargs):
     selectable = expression._clause_element_as_expr(selectable)
     mapname = 'Mapped' + _selectable_name(selectable)
+    # Py2K
     if isinstance(mapname, unicode): 
         engine_encoding = selectable.metadata.bind.dialect.encoding 
         mapname = mapname.encode(engine_encoding)
+    # end Py2K
     if isinstance(selectable, Table):
         klass = TableClassType(mapname, (object,), {})
     else:
index b865c11f46a967cc398330258c529cfe44b6f646..4b002f2a4b827e1f6dd7ae2bb0fe2a7b32f6ccc9 100644 (file)
@@ -529,7 +529,11 @@ class CollectionAdapter(object):
         if getattr(obj, '_sa_adapter', None) is not None:
             return getattr(obj, '_sa_adapter')
         elif setting_type == dict:
+            # Py3K
+            #return obj.values()
+            # Py2K
             return getattr(obj, 'itervalues', getattr(obj, 'values'))()
+            # end Py2K
         else:
             return iter(obj)
 
@@ -561,7 +565,9 @@ class CollectionAdapter(object):
 
     def __iter__(self):
         """Iterate over entities in the collection."""
-        return getattr(self._data(), '_sa_iterator')()
+        
+        # Py3K requires iter() here
+        return iter(getattr(self._data(), '_sa_iterator')())
 
     def __len__(self):
         """Count entities in the collection."""
@@ -1321,9 +1327,14 @@ class InstrumentedSet(set):
 class InstrumentedDict(dict):
     """An instrumented version of the built-in dict."""
 
+    # Py3K
+    #__instrumentation__ = {
+    #    'iterator': 'values', }
+    # Py2K
     __instrumentation__ = {
         'iterator': 'itervalues', }
-
+    # end Py2K
+    
 __canned_instrumentation = {
     list: InstrumentedList,
     set: InstrumentedSet,
@@ -1340,8 +1351,13 @@ __interfaces = {
           'iterator': '__iter__',
           '_decorators': _set_decorators(), },
     # decorators are required for dicts and object collections.
+    # Py3K
+    #dict: {'iterator': 'values',
+    #       '_decorators': _dict_decorators(), },
+    # Py2K
     dict: {'iterator': 'itervalues',
            '_decorators': _dict_decorators(), },
+    # end Py2K
     # < 0.4 compatible naming, deprecated- use decorators instead.
     None: {}
     }
index 66018934e15e964a862bf2751b439e4fca27cef2..5ea22b2fdb511ed5517277b6adbc57e167d6f408 100644 (file)
@@ -222,7 +222,6 @@ class SQLCompiler(engine.Compiled):
         """return a dictionary of bind parameter keys and values"""
 
         if params:
-            params = util.column_dict(params)
             pd = {}
             for bindparam, name in self.bind_names.iteritems():
                 for paramname in (bindparam.key, bindparam.shortname, name):
index 1721f621d3ccf3dd5a4fe9b370a45bbceea719bd..6a456c07ebfb2e45efb6b2840aada211494fc08b 100644 (file)
@@ -376,21 +376,21 @@ class DictlikeIteritemsTest(unittest.TestCase):
 
 
 class DuckTypeCollectionTest(TestBase):
-    # Py3K
-    #pass
-    
-    # Py2K
     def test_sets(self):
+        # Py2K
         import sets
+        # end Py2K
         class SetLike(object):
             def add(self):
                 pass
 
         class ForcedSet(list):
             __emulates__ = set
-
+        
         for type_ in (set,
+                      # Py2K
                       sets.Set,
+                      # end Py2K
                       SetLike,
                       ForcedSet):
             eq_(util.duck_type_collection(type_), set)
@@ -398,11 +398,13 @@ class DuckTypeCollectionTest(TestBase):
             eq_(util.duck_type_collection(instance), set)
 
         for type_ in (frozenset,
-                      sets.ImmutableSet):
+                      # Py2K
+                      sets.ImmutableSet
+                      # end Py2K
+                      ):
             is_(util.duck_type_collection(type_), None)
             instance = type_()
             is_(util.duck_type_collection(instance), None)
-    # end Py2K
 
 class ArgInspectionTest(TestBase):
     def test_get_cls_kwargs(self):
index 0a13002cd8464f392c9215a4ed57859ac2a20bf0..30f1e3da16981bae45b62ddaed28c80a85e2b21b 100644 (file)
@@ -14,9 +14,9 @@ groups = [user, administrator]
 
 def cryptpw(password, salt=None):
     if salt is None:
-        salt = string.join([chr(random.randint(ord('a'), ord('z'))),
-                            chr(random.randint(ord('a'), ord('z')))],'')
-    return sha(password + salt).hexdigest()
+        salt = "".join([chr(random.randint(ord('a'), ord('z'))),
+                            chr(random.randint(ord('a'), ord('z')))])
+    return sha((password+ salt).encode('ascii')).hexdigest()
 
 def checkpw(password, dbpw):
     return cryptpw(password, dbpw[:2]) == dbpw