[ckan-dev] what is the Missing class used for?

Dave Caraway dave at fogmine.com
Sat Sep 7 23:13:08 UTC 2013


Awesome, thanks for sharing Ian. I discovered that, while Missing works for
the ckan.lib.navl.validators functions, it does not work or results in
inconsistent behavior for formencode validators -- who either invoke some
function (e.g. __str__) and raises an Invalid error or who try to
manipulate the Missing instance as a string (e.g. try to trim the string),
both of which result in uncaught errors.

I fixed this and a few other related bugs -- will issue a pull request in
the near future.


On Sat, Sep 7, 2013 at 9:06 AM, Ian Ward <ian at excess.org> wrote:

> Hi Dave,
>
> That's right, Missing is not an exception it's the class for an object
> used to represent fields not passed:
> ckan.lib.navl.dictization_functions.missing. I made some notes the
> last time I was working through that code:
> https://github.com/okfn/ckan/wiki/Converters-and-Validators-in-navl-Schemas
>
> Ian
>
> On Sat, Sep 7, 2013 at 1:41 AM, Dave Caraway <dave at fogmine.com> wrote:
> > Figured it out, I think. The Missing class is used for ignore_missing,
> > ignore_empty and other validator functions defined in
> > ckan.lib.navl.validators. Note that these should not be confused with
> > validators defined in the formencode library, which is also used for HTML
> > form validation.
> >
> >
> >
> >
> >
> > On Fri, Sep 6, 2013 at 5:26 PM, Dave Caraway <dave at fogmine.com> wrote:
> >>
> >> Hi everyone,
> >>
> >> Can anyone explain where instances of the Missing class (an exception)
> in
> >> ckan.lib.navl.dictization_functions.py should be propagated to? Right
> now
> >> they are going uncaught, resulting in a server error for me. Wondering
> if I
> >> should just catch them and add a message to the error object.
> >>
> >> code snippet from ckan.lib.navl.dictization_functions.py:
> >>
> >> class Missing(object):
> >>     def __unicode__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __str__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __int__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __complex__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __long__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __float__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __oct__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __hex__(self):
> >>         raise Invalid(_('Missing value'))
> >>     def __nonzero__(self):
> >>         return False
> >>
> >>
> >> Thanks!
> >> -Dave
> >>
> >> --
> >> Dave Caraway
> >> Owner
> >> Fog Mine
> >> dave at fogmine.com
> >> Cell: (937) 985-0867
> >> Fax: (866) 238-3120
> >
> >
> >
> >
> > --
> > Dave Caraway
> > Owner
> > Fog Mine
> > dave at fogmine.com
> > Cell: (937) 985-0867
> > Fax: (866) 238-3120
> >
> > _______________________________________________
> > ckan-dev mailing list
> > ckan-dev at lists.okfn.org
> > http://lists.okfn.org/mailman/listinfo/ckan-dev
> > Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
> >
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>



-- 
Dave Caraway
Owner
Fog Mine
dave at fogmine.com
Cell: (937) 985-0867
Fax: (866) 238-3120
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130907/9f06f518/attachment-0001.html>


More information about the ckan-dev mailing list