Thank you Markus,
technically they are not allowed but you can do with a trick
db.define_table('ports',
Field('name','string'),
Field('port_agent_id','integer')
)
db.define_table('port_agents',
field('name','string',
Field('port_id', db.ports),
)
db.ports.port_agent_id.requires=IS_IN_DB(db.'port_agents.id','%(name)
s')
db.port_agents.port_id.requires=IS_IN_DB(db.'ports.id','%(name)s')
The port_agent_id reference would not be enforced by the database but
by web2py. On cascade delete would not work. Everything else would.
On Oct 8, 3:59 am, Markus Schmitz <[email protected]> wrote:
> Hi everybody,
>
> After evaluating quite a number of web frameworks, I ended up with
> web2py and frankly I am more than impressed. It rocks in many ways
> (could talk about it for some time really) and fits very close to my
> internal requirements.
>
> But I am a newbee and I am running into newbee problems:
>
> While creating the needed data model, I got stuck with a circular
> reference, which I can not resolve. This might be simply a problem
> with a bad design of my data model, but I will describe it anyway.
>
> I have port_agents, which are assigned to specific ports. One port
> might have several port_agents.
> At the same time each port might have a preferred agent, so my model
> looks something like this:
>
> db.define_table('ports',
> Field('name','string'),
> Field('port_agent_id','references port_agents') # this references
> ahead and does not work
> )
>
> db.define_table('port_agents',
> field('name','string',
> Field('port_id', db.ports),
> )
>
> How can this be done in web2py?
>
> I could use a field 'is preferred agent' on the port agent, but then I
> have to build checks, that nobody else is a preferred agent for this
> port etc.
>
> Any suggestions?
>
> Regards
>
> Markus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---