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 to http://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 at http://paste.turbogears.org/ and post the link here. Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

