Sorry my English isn't the best :-o
You mean that I can't cache select with uploaded files?
And it seems to me that the trouble is only with one particular select
result...
This is my actual code:
-------------------- cut -----------------------
db.define_table( 'invoice',
Field( 'seller_id', db.seller,
label = 'Eladó',
requires = IS_IN_DB( db, 'seller.id', '%(name)s, %(address)s' ) ),
Field( 'number', 'string',
label = 'Számlaszám',
requires = IS_NOT_EMPTY() ),
Field( 'date', 'date',
label = 'Dátum',
requires = IS_NOT_EMPTY(),
default = request.now ),
Field( 'document', 'upload',
label = 'Számla fájl',
uploadfield = 'invoicedata' ),
Field( 'invoicedata', 'blob' ),
)
def szamla():
'''
form for narrowing select
'''
filter_form=SQLFORM.factory(
Field( 'tol', 'date',
label = 'Tól' ),
Field( 'ig', 'date',
label = 'Ig' ),
Field( 'invoice', 'string',
label = 'Számla', ),
table_name = 'szlaform' )
if filter_form.accepts( request.vars, session ):
query=( ( auth.accessible_query( 'read', db.invoice,
auth.user_id ) )&\
( db.invoice.seller_id==db.seller.id ) )
#
# timeframe
#
if filter_form.vars.tol:
query=query&( db.invoice.date>=filter_form.vars.tol )
if filter_form.vars.ig:
query=query&( db.invoice.date<=filter_form.vars.ig )
#
# Szamlaszam
#
if filter_form.vars.invoice:
import re
re_id=re.compile( " \((\d+)\)$" )
# szamlaszam
if re_id.search( request.vars.invoice ):
invoice=re_id.search( request.vars.invoice ).group( 1 )
if ( db( db.invoice.id==invoice ).count()>0 ):
query=query&( db.invoice.id==invoice )
else:
filter_form.errors.invoice='Nincs ilyen számla az adatbázisban!
%s'%invoice
else:
filter_form.errors.invoice='Helytelen bevitel, használd az
autocompletet!'
if not filter_form.errors:
lista=db( query ).select( orderby = db.seller.name ,
cache=(cache.disk,120))
else:
lista=[]
else:
lista=[]
return dict( filter_form = filter_form, lista = lista )
-------------------- cut -----------------------
What's wrong with it?
lista=db( query ).select( orderby = db.seller.name , cache=(cache.disk,
120))
On febr. 28, 13:45, mdipierro <[email protected]> wrote:
> You cannot store in a session the result of a select().
>
> On Feb 26, 2:39 pm, szimszon <[email protected]> wrote:
>
>
>
> > The table has upload field and blob to hold file. Can it cause the
> > problem?
>
> > On febr. 26, 21:22, szimszon <[email protected]> wrote:
>
> > > This is the cached select which caused the trouble:
>
> > > SELECT invoice.id, invoice.seller_id, invoice.number, invoice.date,
> > > invoice.document, invoice.invoicedata, seller.id, seller.name,
> > > seller.address, seller.email, seller.phone, seller.description FROM
> > > invoice, seller WHERE ((invoice.id>0 AND invoice.seller_id=seller.id)
> > > AND invoice.id=370) ORDER BY seller.name;
>
> > > On febr. 26, 16:22, szimszon <[email protected]> wrote:
>
> > > > Error traceback
>
> > > > Traceback (most recent call last):
> > > > File "gluon/restricted.py", line 173, in restricted
> > > > exec ccode in environment
> > > > File "applications/raktar/compiled/controllers_lista_szamla.py",
> > > > line 360, in <module>
> > > > File "gluon/globals.py", line 96, in <lambda>
> > > > self._caller = lambda f: f()
> > > > File "gluon/tools.py", line 1850, in f
> > > > return action(*a, **b)
> > > > File "applications/raktar/compiled/controllers_lista_szamla.py",
> > > > line 74, in szamla
> > > > File "gluon/sql.py", line 3048, in select
> > > > rows = cache_model(key, lambda : response(query), time_expire)
> > > > File "gluon/cache.py", line 305, in __call__
> > > > storage[key] = (time.time(), value)
> > > > File "/usr/lib/python2.5/shelve.py", line 123, in __setitem__
> > > > p.dump(value)
> > > > File "/usr/lib/python2.5/copy_reg.py", line 69, in _reduce_ex
> > > > raise TypeError, "can't pickle %s objects" % base.__name__
> > > > TypeError: can't pickle buffer objects
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.