[web2py] IS_IN_DB() validator only validating on form fields?

2014-03-09 Thread Dan Why
Hi all, 

Working through the official documentation on Chapter 3, on Image blog 
example.

in models.db.py
db.define_table('image', ...)
db.define_table('post', ...)
...

db.post.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')


in controllers/default.py

def show():
image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
db.post.image_id.default = image.id  # --- this line
 ...


I tried removing the line (db.post.image_id.default = image.id), and used 
the non-admin page to insert comments. The comments are inserted into DB. 
On admin page, post.image_id of those comments would show as None. This is 
somewhat surprising to me as I thought they were enforcing referencial 
integrity at DB level. It seems the validatiors are merely for front-end 
validation at form level. Is that correct? If so, does web2py have a way to 
enforce DB level validation? 

Thanks,
Dan

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


[web2py] IS_IN_DB validator dropdown formatting

2014-02-11 Thread Jim S
I'm looking for a way to format the dropdown list generated from a SQLFORM.

I'm using the following code:

db.equipOrder.customerId.requires = IS_IN_DB(query, db.customer, 
('%(customerId)s - %(name)s'), zero='..')

which give me a nice dropdown list showing my customer id and name. 
 However, I'd really like to add a second line to each item in my list that 
displays the city and state where the customer reside.  Is there a way for 
me to do this using the IS_IN_DB validator?

-Jim

-- 
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/groups/opt_out.


[web2py] IS_IN_DB validator

2011-04-23 Thread niknok
Is there a way to sort the list generated by IS_IN_DB by another field
other than the one formatted for display?

Thanks.

/r
Nik 


[web2py] IS_IN_DB validator

2011-04-23 Thread niknok
Is there a way to sort the list generated by IS_IN_DB by another field
other than the one formatted for display?

Thanks.

/r
Nik