Depends on the model. I will assume
db.define_table('org',Field('name'))
db.define_table('eventtype,Field('org',db.org),Field('name'))
In this case
def edit():
org_id, eventtype_id=request.args(0),request.args(1)
eventtype==db.eventtype(eventtype_id,org=org_id) or
redirect(URL(...))
I do not understand the Django example since it is not using the
ord_id information.
On Nov 20, 6:31 pm, Joe J <[email protected]> wrote:
> Hi All,
> I have a one-to-many relationship between a table called "org" and a
> table called "eventtype". (one org can have many eventtypes).
>
> I'm trying to construct a controller function that can edit a
> eventtype belonging to a specific org. The URL might look something
> like:
> /app_name/eventtype/edit/[org_name_id]/[event_type_id]/
>
> I'm like to pass the org_id, and eventtype_id in as arguments to the
> controller function and then return the given eventtype object
> instance only if it belongs to the selected org.
>
> def edit():
> # example I found in the book
> try: org=db.org(request.args(0))
> except: redirect(URL('org','index'))
>
> eventtype_id = request.args(1)
> # trying to find a way to select the eventtype
> # from the orgs available eventtypes. I want
> # the eventtype var to be the selected
> # eventtype instance (not a list of fields)
> try: eventtype=db.eventtype(eventtype_id, db.org???)
> except: redirect(URL('org','index'))
>
> If it helps clarify the question, here is the Django syntax for what I
> am trying to do.
> ....
> try:
> eventtype=org.eventtype_set.get(id=eventtype_id)
> except ....
> return HttpRedirect(...)
>
> Any help is much appreciated. Thank you for reading at this.
> Joe