On Sep 15, 2010, at 10:04 AM, Nikolaj wrote:

> The following test fails in 0.6.4 but not 0.6.3 with AttributeError:
> type object 'Person' has no attribute 'foo'. Is this a deliberate
> change? It seems a bit weird that every @classproperty on a
> declarative subclass is accessed/run on import.
> 
> from sqlalchemy import create_engine, Column, String
> from sqlalchemy.ext.declarative import declarative_base
> from sqlalchemy.util import classproperty
> 
> Base = declarative_base()
> 
> class Person(Base):
>    __tablename__ = 'people'
> 
>    name = Column(String, primary_key=True)
> 
>    @classproperty
>    def bar(cls):
>        return cls.foo

The backrground for this is deliberate, but the effect you are seeing was not 
originally intended.   Person.foo is being evaluated when Person is first 
created by the declarative base, to see if it returns a mapper property.   If 
.foo isn't available there's your error.

The declarative evaluation is limited to the @classproperty decorator that's 
inside of sqlalchemy.util.   If you use your own external @classproperty it 
won't be called upon.


-- 
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.

Reply via email to