Kirk Strauser schrieb:
> Inheritance in WidgetsList classes doesn't work as I'd expect.  For example, 
> suppose I want to make a class hierarchy where a single base class contains a 
> bunch of shared fields, and child classes add extra fields as needed:
> 
> class BaseUserFields(widgets.WidgetsList):
>     email_address = widgets.TextField()
>     display_name = widgets.TextField()
>     password = widgets.PasswordField()
> 
> class EditUser(BaseUserFields):
>     # ID of the user we're editing
>     user_id = widgets.HiddenField()
> 
> class AddUser(BaseUserFields):
>     # We don't have a username yet, so get one
>     user_name = widgets.TextField()
>  
> However, when I display the children as forms, I only see the fields defined 
> directly in the children and none of the parent's fields.
> 
> First, how is that even possible?  I've never seen a Python class that 
> behaves 
> that way (not meant as a criticism, but genuinely curious).

This happens through a meta class that removes all the class attributes, 
putting them into a list. This list is stored in the "declared_widgets" 
class attribute that used to inialize the WidgetList. Since the class 
attributes are removed, subclasses don't see them.

I've suggested a patch in http://trac.turbogears.org/ticket/2014 that 
makes your example above work as intended.

-- Christoph




--~--~---------~--~----~------------~-------~--~----~
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