Fix py33 support

This commit is contained in:
Konsta Vesterinen
2014-03-05 15:47:49 +02:00
parent 12cd7a848d
commit 2bfc40d21d
5 changed files with 12 additions and 8 deletions

View File

@@ -74,7 +74,7 @@ class GenericAttributeImpl(attributes.ScalarAttributeImpl):
pk = mapper.identity_key_from_instance(initiator)[1] pk = mapper.identity_key_from_instance(initiator)[1]
# Set the identifier and the discriminator. # Set the identifier and the discriminator.
discriminator = unicode(class_.__name__) discriminator = six.text_type(class_.__name__)
for index, id in enumerate(self.parent_token.id): for index, id in enumerate(self.parent_token.id):
dict_[id.key] = pk[index] dict_[id.key] = pk[index]
@@ -144,7 +144,7 @@ class GenericRelationshipProperty(MapperProperty):
self._parentmapper = parentmapper self._parentmapper = parentmapper
def __eq__(self, other): def __eq__(self, other):
discriminator = unicode(type(other).__name__) discriminator = six.text_type(type(other).__name__)
q = self.property._discriminator_col == discriminator q = self.property._discriminator_col == discriminator
other_id = identity(other) other_id = identity(other)
for index, id in enumerate(self.property._id_cols): for index, id in enumerate(self.property._id_cols):
@@ -158,9 +158,9 @@ class GenericRelationshipProperty(MapperProperty):
mapper = sa.inspect(other) mapper = sa.inspect(other)
# Iterate through the weak sequence in order to get the actual # Iterate through the weak sequence in order to get the actual
# mappers # mappers
class_names = [unicode(other.__name__)] class_names = [six.text_type(other.__name__)]
class_names.extend([ class_names.extend([
unicode(submapper.class_.__name__) six.text_type(submapper.class_.__name__)
for submapper in mapper._inheriting_mappers for submapper in mapper._inheriting_mappers
]) ])

View File

@@ -1,4 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import six
from tests import TestCase from tests import TestCase
@@ -16,7 +17,7 @@ class GenericRelationshipTestCase(TestCase):
event = self.Event() event = self.Event()
event.object_id = user.id event.object_id = user.id
event.object_type = unicode(type(user).__name__) event.object_type = six.text_type(type(user).__name__)
assert event.object is None assert event.object is None

View File

@@ -1,4 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import six
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy_utils import generic_relationship from sqlalchemy_utils import generic_relationship
from tests.generic_relationship import GenericRelationshipTestCase from tests.generic_relationship import GenericRelationshipTestCase
@@ -52,7 +53,7 @@ class TestGenericRelationship(GenericRelationshipTestCase):
event = self.Event() event = self.Event()
event.object_id = user.id event.object_id = user.id
event.object_type = unicode(type(user).__name__) event.object_type = six.text_type(type(user).__name__)
event.object_code = user.code event.object_code = user.code
assert event.object is None assert event.object is None

View File

@@ -1,4 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import six
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy_utils import generic_relationship from sqlalchemy_utils import generic_relationship
@@ -55,7 +56,7 @@ class TestGenericRelationship(TestCase):
event = self.Event(transaction_id=1) event = self.Event(transaction_id=1)
event.object_id = user.id event.object_id = user.id
event.object_type = unicode(type(user).__name__) event.object_type = six.text_type(type(user).__name__)
assert event.object is None assert event.object is None
self.session.add(event) self.session.add(event)

View File

@@ -1,4 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import six
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy_utils import generic_relationship from sqlalchemy_utils import generic_relationship
from tests import TestCase from tests import TestCase
@@ -54,7 +55,7 @@ class TestGenericRelationship(TestCase):
event = self.Event() event = self.Event()
event.object_id = manager.id event.object_id = manager.id
event.object_type = unicode(type(manager).__name__) event.object_type = six.text_type(type(manager).__name__)
assert event.object is None assert event.object is None