On 10/12/2010 17:09, Michael Bayer wrote:
On Oct 12, 2010, at 7:39 AM, Julien Cigar wrote:

Hello,

any idea why with

# Query

class BaseQuery(orm.Query):
        @dynamic
        def method_a(self):
                ...
        def method_b(self):
                ...

class FooQuery(BaseQuery):
        ...

class BarQuery(FooQuery):
        @dynamic
        def method_c(self):
                ...

# Models

class BaseModel(object):
        query = Session.query_property(BaseQuery)

#

myQuery = type('PolymorphicQuery, (content.BaseQuery, ), func_list)(BaseModel)

where "func_list" containing all the functions decorated by @dynamic the 
following fail? :

- myQuery.get(45) fails with: AttributeError: 'NoneType' object has no 
attribute 'identity_map'
- myQuery.method_a().all() fails with: AttributeError: 'NoneType' object has no 
attribute '_autoflush'
- etc

My goal is to be able to build a custom Query object to use with the 
.with_polymorphic() function ..
I've just grepped through all the source, examples and tests plus the wiki 
trying to find what @dynamic is.   Seems like something I'd have come up with 
in the past but I've no clue at the moment what that is.



Sorry, I forgot to mention that it's just a custom decorator of mine which add the function name to a list ... forget about it, it's just to build the third argument of type() (func_list in my case)

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

<<attachment: jcigar.vcf>>

Reply via email to