I receive the following error with SA 0.4.7p1 and the latest 0.4 svn
revision.

"AttributeError: 'property' object has no attribute 'impl'"

Mappers
======

mapper(TransactionType, transaction_types)

    transactions_mapper = mapper(Transaction, transactions,
order_by=transactions.c.date,
        extension=[HistoryMapperExtension(),
TransactionDateMapperExtension()],
        polymorphic_on=transactions.c.transaction_type_id,
polymorphic_identity=0,
        exclude_properties=['number', 'address', 'shipping',
'handling', 'purchase_order',
                            'contact_note', 'notes', 'valid_until'],
        properties={
            '_voided_at': transactions.c.voided_at,
            '_date': transactions.c.date,
            'method': relation(PaymentMethodType,
backref='transactions'),
            'transaction_type': relation(TransactionType,
backref='transactions'),
            'created_by_id': transactions.c.created_by,
            'updated_by_id': transactions.c.updated_by,
            'created_by': relation(Contact,
primaryjoin=transactions.c.created_by==contacts.c.id),
            'updated_by': relation(Contact,
primaryjoin=transactions.c.updated_by==contacts.c.id),
    })

    mapper(Cost, inherits=transactions_mapper, polymorphic_identity=1,
properties={
        'line_items': relation(LineItem, backref='cost',
cascade='delete')
    })
    mapper(Payment, inherits=transactions_mapper,
polymorphic_identity=2)

    mapper(Receipt, inherits=transactions_mapper,
polymorphic_identity=4)
    mapper(Adjustment, inherits=transactions_mapper,
polymorphic_identity=5)

    abstract_sales_mapper = mapper(AbstractSale,
inherits=transactions_mapper,
 
polymorphic_on=transactions.c.transaction_type_id,
                                   properties={
        'number': transactions.c.number,
        'address': transactions.c.address,
        'shipping': transactions.c.shipping,
        'handling': transactions.c.handling,
        'purchase_order': transactions.c.purchase_order,
        'contact_note': transactions.c.contact_note,
        'notes': transactions.c.notes,
        'payment_terms': relation(PaymentTerm,
backref='abstract_sales'),
        'line_items': relation(LineItem, backref='sale',
cascade='delete', order_by=line_items.c.position)
    })

    mapper(Sale, inherits=abstract_sales_mapper,
polymorphic_identity=3)

    mapper(Quote, inherits=abstract_sales_mapper,
polymorphic_identity=6, properties={
        '_valid_until':
transactions.c.valid_until
    })


The error occurs when performing a query on Transaction ex:
Transaction.query.get(111)
where row id 111 is a Quote type. If a query uses the specific class
type ex: Quote.query.get(111)
it completes successfully.

I don't know if this is an SA bug or an error in my mappers. Any help
is appreciated.

-brad




Full Traceback
===========
In [53]: m.Transaction.query.get(112)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (141, 0))

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

C:\Documents and Settings\bwells\workspace\ERP GIT TEST\erp\<ipython
console> in <module>()

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in get(self, ident, **kw
args)
    267
    268         key = self.mapper.identity_key_from_primary_key(ident)
--> 269         return self._get(key, ident, **kwargs)
    270
    271     def load(self, ident, raiseerr=True, **kwargs):

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in _get(self, key, ident
, refresh_instance, lockmode, only_load_props)
   1066         try:
   1067             # call using all() to avoid LIMIT compilation
complexity
-> 1068             return q.all()[0]
   1069         except IndexError:
   1070             return None

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in all(self)
    876
    877         """
--> 878         return list(self)
    879
    880

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in iterate_instances(sel
f, cursor, *mappers_or_columns, **kwargs)
   1001                 rows = []
   1002                 for row in fetch:
-> 1003                     process[0](context, row, rows)
   1004             elif single_entity:
   1005                 rows = [process[0](context, row) for row in
fetch]

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in main(context, row, re
sult)
   1579                     row = context.row_adapter(row)
   1580                 self.mapper._instance(context, row, result,
-> 1581                     extension=context.extension,
only_load_props=context.only_load_props, refresh_instance=conte
xt.refresh_instance
   1582                 )
   1583         elif context.row_adapter:

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\mapper.pyc in _instance(self, cont
ext, row, result, polymorphic_from, extension, only_load_props,
refresh_instance)
   1366                     raise exceptions.AssertionError("No such
polymorphic_identity %r is defined" % discriminator
)
   1367                 if mapper is not self:
-> 1368                     return mapper._instance(context, row,
result=result, polymorphic_from=self)
   1369
   1370         # determine identity key

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\mapper.pyc in _instance(self, cont
ext, row, result, polymorphic_from, extension, only_load_props,
refresh_instance)
   1457
   1458                 if 'populate_instance' not in
extension.methods or extension.populate_instance(self, context, ro
w, instance, only_load_props=attrs, instancekey=identitykey,
isnew=isnew) is EXT_CONTINUE:
-> 1459                     self.populate_instance(context, instance,
row, only_load_props=attrs, instancekey=identityke
y, isnew=isnew)
   1460
   1461         if result is not None and ('append_result' not in
extension.methods or extension.append_result(self, con
text, row, instance, result, instancekey=identitykey, isnew=isnew) is
EXT_CONTINUE):

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\mapper.pyc in populate_instance(se
lf, selectcontext, instance, row, ispostselect, isnew,
only_load_props, **flags)
   1507
   1508         for (key, populator) in populators:
-> 1509             selectcontext.exec_with_path(self, key, populator,
instance, row, ispostselect=ispostselect, isnew=i
snew, **flags)
   1510
   1511         if self.non_primary:

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in exec_with_path(self,
mapper, propkey, fn, *args, **kwargs)
   1701         self.path += (mapper.base_mapper, propkey)
   1702         try:
-> 1703             return fn(*args, **kwargs)
   1704         finally:
   1705             self.path = oldpath

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\strategies.pyc in new_execute(inst
ance, row, isnew, **flags)
     84             def new_execute(instance, row, isnew, **flags):
     85                 if isnew:
---> 86
instance._state.expire_attributes([self.key])
     87             if self._should_log_debug:
     88                 self.logger.debug("Deferring load for %s %s" %
(mapper, self.key))

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\attributes.pyc in expire_attribute
s(self, attribute_names)
    870                 self.committed_state.pop(key, None)
    871                 self.expired_attributes.add(key)
--> 872                 if getattr(self.class_,
key).impl.accepts_scalar_loader:
    873                     self.callables[key] = self
    874

AttributeError: 'property' object has no attribute 'impl'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to