apologies for this question - I see it's been popular over the years - but 
I can't find the definitive answer.

How can I either:
a) handle the case of have no references to insert? or
b) avoid the duplication of two db inserts that are identical except one is 
missing a field that can't be set to None.?

Note: I am not building a HTML ui from the database definition but 
inserting data via code.

in my db.py:

db.define_table('item', ..., Field('geoPts', 'list:reference geoPt'), ...)

in a module:

pts = # set to a list of zero or more db id values

if pts:
    db.item.insert(
        ...
        geoPts=pts,
        ....)

else:
    db.item.insert(
        ...
        # note that we don't try and set geoPts to None
        ....)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to