Hi,

Your TaskExtension class doesn't have a translate_row method, which
apparently is part of the MapperExtension interface (although it doesn't
appear in the docs). From the source code (in orm/mapper.py):

    def translate_row(self, mapper, context, row):
        """Perform pre-processing on the given result row and return a
        new row instance.

        This is called as the very first step in the ``_instance()``
        method.
        """

        return EXT_PASS

You could make life much easier for yourself by making TaskExtension
inherit from MapperExtension. In that way you would only need to
implement the methods that you actually want to override, and you won't
have to update your extension class every time new extension methods are
added.

Hope that helps,

Simon


> -----Original Message-----
> From: [email protected] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Sanjay
> Sent: 04 May 2007 14:37
> To: sqlalchemy
> Subject: [sqlalchemy] Re: 'MapperExtension' object has no 
> attribute 'translate_row'
> 
> 
> > testcase please
> 
> Here is the sample code which works perfectly till 0.3.4 and produces
> error in newer versions in my system:
> 
> from sqlalchemy import *
> from sqlalchemy.ext.assignmapper import assign_mapper
> from sqlalchemy.ext.sessioncontext import SessionContext
> 
> context = SessionContext(create_session)
> session = context.current
> 
> metadata = BoundMetaData('sqlite:///satest', echo=False)
> 
> task_tbl = Table('task', metadata,
>     Column("task_id", Integer, primary_key=True, autoincrement=True),
>     Column("descr", Unicode(30), nullable=False))
> 
> metadata.drop_all()
> metadata.create_all()
> 
> class Task(object):
>     pass
> 
> from sqlalchemy import EXT_PASS
> 
> class TaskExtension(object):
> 
>     def get_session(self):
>         return EXT_PASS
>     def select_by(self, query, *args, **kwargs):
>         return EXT_PASS
>     def select(self, query, *args, **kwargs):
>         return EXT_PASS
>     def get_by(self, query, *args, **kwargs):
>         return EXT_PASS
>     def get(self, query, *args, **kwargs):
>         return EXT_PASS
>     def create_instance(self, mapper, selectcontext, row, class_):
>         return EXT_PASS
>     def append_result(self, mapper, selectcontext, row, instance,
> identitykey, result, isnew):
>         return EXT_PASS
>     def populate_instance(self, mapper, selectcontext, row, instance,
> identitykey, isnew):
>         mapper.populate_instance(selectcontext, instance, row,
> identitykey, isnew)
>     def before_insert(self, mapper, connection, instance):
>          return EXT_PASS
>     def before_update(self, mapper, connection, instance):
>         return EXT_PASS
>     def after_update(self, mapper, connection, instance):
>         return EXT_PASS
>     def after_insert(self, mapper, connection, instance):
>         return EXT_PASS
>     def before_delete(self, mapper, connection, instance):
>         return EXT_PASS
>     def after_delete(self, mapper, connection, instance):
>         return EXT_PASS
> 
> assign_mapper(context, Task, task_tbl, extension=TaskExtension())
> 
> t = Task(descr='xyz')
> t.flush()
> session.clear()
> t = Task.get(1) # produces exception
> 
> 
> 
> > 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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