-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12 Jun 2008, at 02:06, Hans wrote:

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

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

> AttributeError: 'Director' object has no attribute 'movies'


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


I don't /think/ so. Try adding the line

setup_all()

after your object specification:

Like this:

> 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
>
> setup_all()
>
> rscott = Director(name="Ridley Scott")
> brunner = Movie(title="Blade Runner", year=1982)
> rscott.movies.append(brunner)
> print rscott.movies


HTH

Cheers,

Graham



-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkhQ93YACgkQOsmLt1NhivyuHwCfXWB3I81ZI6UK/AJtLMQR21VP
dcQAoKMIx1Ad9UmXg4UEEdS5ZKmBuYtViQCVAgUBSFD3dlnrWVZ7aXD1AQI93wP5
AVtIuPx329zSG2vJt8NLWKSqXXzU9O4gOLT9Ym9FO5zEBqndp8eg+g5XA2l0ZYza
jXG1jsFzyIVtLJq+QZBonrUq1w2WTqw2HeHgPhVrOARfGpGhn0PTPLAfypfL5RE0
VloWEz+Z3K04FGPZj0xgVWmIXbvyNdNX44dz5SOZ2ow=
=JWpo
-----END PGP SIGNATURE-----


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