Rails does this so effortlessly I couldn't believe TG 1.1 doesn't.

To accomplish this I have the following as the base of all my DB model
objects:

<code>
# the identity model

class DBObject(object):

  def __init__(self):
    object.__init__(self)

  def get_values(self):
    values = {}
    for a in self._sa_class_manager:
      try:
        values[a] = self.__getattribute__(a)
      except:
        pass
    return values
</code>

If you ensure that your form widget fields have the same name as your
DB columns you can then populate the form quickly with something like:

<code>
    user = session.query(User).filter(User.user_id == 1).first()
    form = forms.edit_user.form

    return {
      "form" : form,
      "values" : user.get_values()
    }
</code>

Have I reinvented the wheel ? Does TG already have this kind of
thing ?

--

Also: Form Inheritance and field ordering.

If I inherit form B from form A and if form B adds additional fields
(such as may be hidden from a normal user but visible to an admin
user) is it possible to affect the ordering of these field when
displayed ? Current ordering seems to be strictly declaration order.

Regards,

t o b e
--~--~---------~--~----~------------~-------~--~----~
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