On Oct 18, 10:10 pm, Gregor Horvath <[EMAIL PROTECTED]> wrote:

> def dict_to_attr(dict_, object_):
>   valid_attributes = object_.sqlmeta.columns.keys()
>   for attr, value in dict_.iteritems():
>     if attr in valid_attributes:
>         setattr(object_, attr, value)
>

This saves me a lot of work, but how do I get the type?
I still need to cast for my IntCols.

Can I just get the column value from the object and check it's type?

Like this:
-----------------------
def dict_to_attr(dict_, object_):
  valid_attributes = object_.sqlmeta.columns.keys()
  for attr, value in dict_.iteritems():
    if attr in valid_attributes:
       colCheck = getattr(object_, attr)    # get the column-value

       if( type(colCheck) == int ):   # check it's type
          type = int(type)                # 'cast' it

       setattr(object_, attr, value)
--------------------------

Hm, I really need to setup a test-model so I don't have to
try testing this trough TurboGears.

Tor


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

Reply via email to