Try:

db._adapter.uploads_in_blob = True

Then, when you do:

db.define_table('mytable', Field('myfile', 'upload', uploadfield=True))

you should get a blob field called db.mytable.myfile_blob with the readable 
and writable attributes set to False.

Also, feel free to submit a Google Code issue requesting a feature that 
allows this to be set database-wide via an argument to DAL().

Anthony

On Monday, May 19, 2014 1:37:11 PM UTC-4, Mandar Vaze wrote:
>
> Currently I am using "uploadfield" option of "Field"/table definition to 
> ensure that uploads are stored in DB and not on the filesystem.
>
> While this works, this seems tedious because :
>
> 1. I have multiple tables with upload fields. If I forget defining 
> "uploadfield" even one of them (or if someone forgets in future, when they 
> add a new table) then I will end up having some uploads in the DB, and some 
> on the filesystem
> 2. I need to explicitly "hide" the blob field, otherwise it shows up in 
> the SQLFORM.grid
>
> *Is there a cleaner option ?*
>
> I tried defining "db" in models/db.py as follows :
>
> db = DAL('postgres://user:pass@localhost/mydb', pool_size=5,check_reserved
> =['all'], adapter_args={'uploads_in_blob': True})
>
> But it does not seem to work
>
> I dug a little, but was unable to find how and where adapter_args were 
> used. It seems it is finally passed to self.find_driver - but at least for 
> psycopg2 driver
>
> -Mandar
>
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to