So do you mean for, say, humans.py:
humans.py:
-----------
from elixir import Field, Unicode, OneToMany, Entity
from tgmultifilemodel.model import *
class Man(Entity):
name = Field(Unicode(10))
pets = OneToMany('Dog')
def __repr__(self):
return '<Man \'%s\'>' % (self.name)
This doesn't seem to work... it creates the key error I described
above.
-Dan
On Apr 30, 6:10 pm, alex bodnaru <[EMAIL PROTECTED]> wrote:
> to avoid unnatural full address, which will further complicate after each
> import, use from model import *.
>
> Gaetan de Menten wrote:
> > Yeah, that's the only reliable method currently. Thanks for digging in
> > the mailing list archive for the answer!
> > I've had an answer to DanL message in my draft folder for quite a
> > while now (no idea why I didn't send it when I wrote it :-/).
>
> > I'll definitely need to address this in a FAQ or even the tutorial
> > given the number of people who trip on this...
>
> > On Wed, Apr 30, 2008 at 10:56 AM, Yap Sok Ann <[EMAIL PROTECTED]> wrote:
> >> On Apr 30, 11:32 am, Yap Sok Ann <[EMAIL PROTECTED]> wrote:
> >> > The model below doesn't seem to work with any of the import methods
> >> > laid out in this discussion and in the wiki. It has an "odd many-to-
> >> > many relationship" which is modeled following Gaeten's suggestion
> >> inhttp://www.mail-archive.com/[EMAIL PROTECTED]/msg02616.html
>
> >> > man.py
> >> > ------
> >> > from elixir import Entity, Field, Unicode, has_many
>
> >> > class Man(Entity):
> >> > name = Field(Unicode(10))
> >> > has_many('relationships', of_kind='Relationship')
> >> > def __repr__(self):
> >> > return '<Man \'%s\'>' % (self.name)
>
> >> > woman.py
> >> > --------
> >> > from elixir import Entity, Field, Unicode, has_many
>
> >> > class Woman(Entity):
> >> > name = Field(Unicode(10))
> >> > has_many('relationships', of_kind='Relationship')
> >> > def __repr__(self):
> >> > return '<Woman \'%s\'>' % (self.name)
>
> >> > relationship.py
> >> > ---------------
> >> > from elixir import Entity, Field, Unicode, belongs_to
>
> >> > class Relationship(Entity):
> >> > name = Field(Unicode(10))
> >> > belongs_to('man', of_kind='Man', required=True)
> >> > belongs_to('woman', of_kind='Woman', required=True)
> >> > def __repr__(self):
> >> > return '<Relationship \'%s\'>' % (self.name)
>
> >> > Tested under Elixir 0.5.2
>
> >> I got it to work using full path addressing as mentioned by Gaeten in
> >>
> >> http://groups.google.com/group/sqlelixir/browse_thread/thread/bc8b23a1ae8bd9ec
>
> >> Dan, can you try if it works for you? Should work fine regardless of
> >> how to structure the files or where to do the import.
>
> >> FWIW, here's what I have:
>
> >> model/__init__.py
> >> -----------------
>
> >> model/man.py
>
> >> ------------
> >> from elixir import Entity, Field, Unicode, has_many
>
> >> class Man(Entity):
> >> name = Field(Unicode(10))
> >> has_many('relationships', of_kind='model.relationship.Re
> >> lationship')
> >> has_many('women', through='relationships', via='woman')
>
> >> def __repr__(self):
> >> return '<Man \'%s\'>' % (self.name)
>
> >> model/woman.py
>
> >> --------------
> >> from elixir import Entity, Field, Unicode, has_many
>
> >> class Woman(Entity):
> >> name = Field(Unicode(10))
> >> has_many('relationships',
> >> of_kind='model.relationship.Relationship')
> >> has_many('men', through='relationships', via='man')
>
> >> def __repr__(self):
> >> return '<Woman \'%s\'>' % (self.name)
>
> >> model/relationship.py
>
> >> ---------------------
> >> from elixir import Entity, Field, Unicode, belongs_to
>
> >> class Relationship(Entity):
> >> name = Field(Unicode(10))
> >> belongs_to('man', of_kind='model.man.Man',
> >> inverse='relationships', required=True)
> >> belongs_to('woman', of_kind='model.woman.Woman',
> >> inverse='relationships', required=True)
>
> >> def __repr__(self):
> >> return '<Relationship \'%s\'>' % (self.name)
>
> >> test.py
> >> -------
> >> from elixir import Entity, setup_all
>
> >> from model.man import Man
> >> from model.woman import Woman
> >> from model.relationship import Relationship
>
> >> print Entity.__metaclass__._entities
>
> >> setup_all()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---