1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Rep Power

    WTForms self.form.process obj= always None

    my problem is that even after passing in a custom object and confirming that it is not None it appears to be None when logging info on form.py
    def process(self, formdata=None, obj=None, **kwargs):

    Any idea why its None by the time it gets to teh obj argument but not None before?

    currently trying to use form mixins :

    blain = models.bla.get_All_byefg(efg.key) 
    cbla = blablaclass(efg,blain ) 
    self.form.process(obj=cbla )
    in mytest.py:
    class blablaclass(object): def __init__(self, efg, abc): self.abc=abc
    self.efg= efg

    in forms.py
    class blaMixin(BaseForm): efg= fields.FormField(blaMixin) 
    abc= fields.FieldList(fields.FormField(blablaMixin))
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Usually Japan when not on contract
    Rep Power
    I have no idea what library this is and you didn't provide much context for discussion... That said...

    You checked that the object actually exists at the label you gave it. So it might be that the function you are passing it to is asking the object a question that its answering None to, instead of the object itself actually being a NoneType.
    python Code:
    >>> def get_name(o):
    ...   print o.name
    >>> class Mine(object):
    ...   def __init__(self, name=None):
    ...     self.name = name
    >>> c = Mine()
    >>> type(c)
    <class '__main__.Mine'>
    >>> get_name(c)

    The object named "c" exists, buts its name was initialized to None by default (whoops!) -- and when asking get_name() to tell us the name its saying "None" -- which could make it appear that c itself is None if we don't understand what is going on within get_name() and c.

    I'm not sure that this is what's going on, but it might be a good idea to check some of the code in the class/method soup you're swimming in, since it sounds like you're certain your object does indeed exist (and if it didn't exist at all you'd get a name error).

IMN logo majestic logo threadwatch logo seochat tools logo