Hi -

I'm running latest (released) Elixir + SQLAlchemy on Gentoo w/ Python
2.4.

I'm brand new to Elixir so I was walking through the tutorial to see
how it all works.  I setup my model.py per the instructions:
------------------
from elixir import *

metadata.bind = "sqlite:///movies.sqlite"
metadata.bind.echo = True

class Movie(Entity):
    title = Field(Unicode(30))
    year = Field(Integer)
    description = Field(Unicode)
    director = ManyToOne('Director')

    def __repr__(self):
        return '<Movie "%s" (%d)>' % (self.title, self.year)

class Director(Entity):
    name = Field(Unicode(60))
    movies = OneToMany('Movie')

    def __repr__(self):
        return '<Director "%s">' % self.name
-------------------------

... but I got stuck trying to execute these lines (condensed for sake
of example):

>>> rscott = Director(name="Ridley Scott")
>>> brunner = Movie(title="Blade Runner", year=1982)
>>> rscott.movies.append(brunner)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'Director' object has no attribute 'movies'

I dug around a little but didn't see an obvious note about this
anywhere.  I decided to look at the videostore example source code,
where I noticed a difference in how the relationships were defined.
Specifically, the use of "inverse":

director = ManyToOne('Director', inverse='movies')
...
movies = OneToMany('Movie', inverse='director')

Passing the inverse param to the relationship classes fixed the
problem for me.  (So now I continue on with the tutorial.)

I would have filed a ticket, but it looks like I need to request a
Trac account first.  I would also be happy to update the wiki page,
but obviously would need a Trac account for that too.

I don't know if this is related to using Python 2.4 ... or ... ?

Thanks,
Hans
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to