Sorry, it's Order as the correct model.

btw, i think i have described my question clearly, just asking for
help for any example of displaying all related "child" models  on the
"show" form of "parent" model.

in my scenario, likewise, on http://localhost:8080/orders/show/1, i
hope to display all of orderitems belonging to Order 1.

pls forgive me, i'm novice on Python as well as Turbogears, i can't
find any full example of one-to-many relation over Google, including
how to display them together on "parent model"'s showing form

Thanks anyway

On Oct 21, 12:50 pm, Christopher Arndt <[EMAIL PROTECTED]> wrote:
> PigletWatcher schrieb:
>
>
>
>
>
> > I implement one-to-many relationship between Order and OrderItem
> > models.
>
> > in the OrderController.py
>
> > @expose(template='kid:test.OrderController.templates.show')
> >     def show(self,id, **kw):
> >         """Show record in model"""
> >         record = Order.get(int(id))
> >         orderItems = NetworkGroup.all_related_orderItems(id)
> >         return dict(record = record, orderItems=orderItems)
>
> > in the Order class in  model.py:
>
> > def all_related_orderItems(self,id):
> >         return [orderItem for orderItem in self.orderItems
> >                 if (orderItem.groupID == id)]
>
> > but when browsing tohttp://localhost:8080/Orders/show/1
>
> > It throws the message that unbound method all_related_orderItems()
> > must be called with Order instance as first argument.
>
> Are you sure you mean "Order" not "NetworkGroup"? Because in your first
> example above you call the "all_related_orderItems" on the
> "NetworkGroup" class, not on the "Order" class.
>
> Also, if you want to call the method on a class, it must be a class,
> method, so that it receives the class as the first argument, not an
> instance (there is no instance, when calling the method on the class).
>
> But from your code I can't deduce the relationships between you model
> since there are several inconsistencies in the example code you post.
>
> Please paste you model.py code athttp://paste.turbogears.org/and post
> the link here.
>
> Chris- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to