mapped attribute throws AttributeError: 'symbol' object has no attribute

50 views
Skip to first unread message

Adrian

unread,
Oct 12, 2011, 11:17:39 AM10/12/11
to sqlal...@googlegroups.com
When I try to access a specific mapped attribute the error below is thrown but only if I use a custom __eq__(). 

    def __eq__(self, other):
        '''
        '''
        return self.aromatic_ring_id == other.aromatic_ring_id

When I print the type of both, the 'other' class is 'symbol': <class 'credoscript.models.aromaticring.AromaticRing'> <class 'sqlalchemy.util.langhelpers.symbol'>

Any ideas what went wrong?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/adrian/<ipython console> in <module>()

/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.7.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/attributes.pyc in __get__(self, instance, owner)
    166             return dict_[self.key]
    167         else:
--> 168             return self.impl.get(instance_state(instance),dict_)
    169 
    170 def create_proxied_attribute(descriptor):

/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.7.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/attributes.pyc in get(self, state, dict_, passive)
    422                     value = ATTR_EMPTY
    423 
--> 424                 if value in (PASSIVE_NO_RESULT, NEVER_SET):
    425                     return value
    426                 elif value is ATTR_WAS_SET:

/home/adrian/Software/credoscript/models/aromaticring.py in __eq__(self, other)
     48         '''
     49         print type(self), type(other)
---> 50         return self.aromatic_ring_id == other.aromatic_ring_id
     51 
     52     def __ne__(self, other):

AttributeError: 'symbol' object has no attribute 'aromatic_ring_id'

Michael Bayer

unread,
Oct 12, 2011, 11:35:23 AM10/12/11
to sqlal...@googlegroups.com
Please try out the dev tip, 0.7.3, which is at http://hg.sqlalchemy.org/sqlalchemy/archive/default.tar.gz .  There's been a fix regarding attribute access upon objects that redefine __eq__(), which should never be called by SQLAlchemy and this looks like exactly that same issue.


--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/3kqkVsvmxQ8J.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Reply all
Reply to author
Forward
0 new messages