Thanks Anthony. I realize that it's not part of the normal API. But I'm working on a plugin to filter one form field based on the value of another (refreshable via ajax). So I'm extending the OptionsWidget class and needed to figure out where that class got its set of options from. I realize this is not a "standard use" scenario, but if we want people to write plugins like this we need to make it easy to get at the internals. It took me another hour or so to figure out how to get the referenced table for a reference field. Enough of my questions on this list seem to be of this kind that I just think it would save your time if it were documented somewhere -- not necessarily in the book, but if it's not somewhere I may make some of my own notes public.
Cheers, Ian On Saturday, March 31, 2012 1:37:05 PM UTC-4, Anthony wrote: > > You might find this helpful: > http://www.web2py.com/examples/static/epydoc/index.html. It is linked > from http://www.web2py.com/examples/default/documentation. > > Note, the options() method belongs to the IS_IN_SET and IS_IN_DB validator > classes. By default, reference fields get an IS_IN_DB validator, hence the > options() method on field.requires for reference fields. I'm not sure that > the options() method of these two validators would be considered part of > the web2py API -- I think they are only intended to be used as internal > methods by the OptionsWidget, RadioWidget, and CheckboxesWidget classes to > generate options for SQLFORM fields. That's probably why it's not > documented in the book. > > Anthony > > On Saturday, March 31, 2012 12:25:50 PM UTC-4, monotasker wrote: >> >> Maybe it's just me, but one of the things I find most confusing as I work >> with web2py is figuring out what properties and methods each object has. >> For example, I just learned that field.requires can have an options() >> method that outputs a list of tuples for the options available in a >> reference field. I really like the documentation in the web2py book because >> it's oriented toward helping people actually build apps. But is there any >> documentation of the data structure? I would find it enormously helpful to >> have a "map" of the various objects returned by, say, DAL and SQLFORM, >> listing all of their possible properties and methods. I know that this is >> (in theory) available by simply reading the source code (that's how I >> learned about the .options() method). But for those like myself who are not >> full-time code gurus it would be a huge help to have this all a little more >> accessible. >> >

