Hi Michael,
going down the way you pointed I ran into what might be a small bug in
sqlalchemy: Trying to print out a RelationshipProperty I get
project_leader Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File
"/home/rforkel/projects/gulpenv/lib/python2.6/site-packages/sqlalchemy/orm/properties.py",
line 724, in __str__
return str(self.parent.class_.__name__) + "." + self.key
AttributeError: 'RelationshipProperty' object has no attribute 'parent'
>>> import sqlalchemy
>>> sqlalchemy.__version__
'0.7.2'
Anyway, your hint solved my problem, thanx!
regards
robert
On Mon, Oct 17, 2011 at 7:10 PM, Michael Bayer <[email protected]> wrote:
>
> On Oct 17, 2011, at 5:40 AM, Robert Forkel wrote:
>
>> Hi all,
>> Using sqlalchemy 0.7.2 I created a couple of mixin classes (say Mixin)
>> to share columns declarations between model classes (say A and B).
>> Sometimes I have to create instances of type B initialized with the
>> values of an existing object of type A for the columns declared by
>> Mixin. I'd like to make this code extensible with respect to the
>> columns declared in Mixin, i.e. adding new columns to Mixin should
>> require updating this code.
>> Is there a way to find the names of column properties contributed by a
>> Mixin?
>> (I tried with checking Mixin.__dict__ for items of type
>> sqlalchemy.schema.Column, but this doesn't give foreign keys declared
>> via @declared_attr)
>> best regards
>> robert
>
> the mixin is pretty much what you see there, a Python class with some
> attributes. @declared_attr doesn't do anything except allow the function to
> act like an attribute at the class level (it's just one line), and also is a
> "marker" object recognized by Declarative. So if you wanted to see what a
> certain attribute had, you'd call it, that is, instead of looking in
> __dict__, you'd say:
>
> for attr in dir(MyMixin):
> value = getattr(MyMixin, attr)
> # inspect "value"
>
>
> --
> 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.
>
>
--
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.