I'm trying to create a hierarchical database object:
db.define_table('object',
SQLField('oid','integer',default=0), # id of parent
object
SQLField('name','string'),
SQLField('description','text')
)
When I insert a new object via the db app interface, I want to be able
to set the oid via a db lookup, like this:
db.object.oid.requires=IS_IN_DB(db,'object.id','%(name)s')
The problem with this approach is that it requires an entry. If this
is the first entry, it won't work. And what if I don't want the object
to be contained within another object?
So really, I want to be able to do something like this, but I don't
know the right way to do it. This obviously doesn't work:
db.object.oid.requires=IS_IN_SET([Null,IS_IN_DB(db,'object.id','%(name)
s')]
So what IS the right way to do it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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
-~----------~----~----~----~------~----~------~--~---