Simple Image Browser - Error

37 views
Skip to first unread message

David

unread,
Nov 24, 2009, 8:03:23 AM11/24/09
to web2py-users
I am trying to follow the example here:

http://www.web2py.com/AlterEgo/default/show/138


But I keep getting this error:

The problem is that I don't understand why there is an error on line
20 and there is no line 20 in my controller. I don't understand how
that is getting appended. I thought perhaps it was something I did in
my app but I created a test app and I still get the error using the
code from the link above as a reference.

======================
Error traceback

Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 182, in
restricted
ccode = compile(code.replace('\r\n', '\n'), layer, 'exec')
File "/home/www-data/web2py/applications/test/controllers/
default.py", line 20
response._vars=response._caller(index)
^
SyntaxError: invalid syntax


In file: /home/www-data/web2py/applications/test/controllers/
default.py
Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 182, in
restricted
ccode = compile(code.replace('\r\n', '\n'), layer, 'exec')
File "/home/www-data/web2py/applications/test/controllers/
default.py", line 20
response._vars=response._caller(index)
^
SyntaxError: invalid syntax


=====
def index():
form=SQLFORM(db.image)
if form.accepts(request.vars): response.flash='record inserted'
images=db().select(db.image.ALL,orderby=db.image.title)
return dict(form=form,images=images)

def edit():
image=db(db.image.id==request.args[0]).select()[0]
form=SQLFORM(db.image,image,upload=URL(r=request,f='download'))
if form.accepts(request.vars): redirect(URL(r=request,f='index'))
return dict(form=form)

def download():
import os
from gluon.contenttype import contenttype
image=db(db.image.filename==request.args[0]).select()[0]
response.headers['Content-Type']=contenttype(image.filename)
return response.stream(os.path.join
(request.folder,'uploads',image.filename)

response._vars=response._caller(index)

==========================

mdipierro

unread,
Nov 24, 2009, 11:30:14 AM11/24/09
to web2py-users
wow that page is old (and contains some errors). It is much easier
than that now.
I edited the page

Massimo

Pynthon Pynthon

unread,
Nov 24, 2009, 11:41:36 AM11/24/09
to web...@googlegroups.com
Sorry for hijackthis your mail but does the like operator still not work?

2009/11/24 mdipierro <mdip...@cs.depaul.edu>

mdipierro

unread,
Nov 24, 2009, 11:56:40 AM11/24/09
to web2py-users
Google still does not support them. web2py provides a workaround to
execute the filtering at the Python level:

http://www.web2py.com/AlterEgo/default/show/248

Not as good as if the back-end could do it but useful for small data
sets.

Massimo

On Nov 24, 10:41 am, Pynthon Pynthon <forumx...@gmail.com> wrote:
> Sorry for hijackthis your mail but does the like operator still not work?
>
> 2009/11/24 mdipierro <mdipie...@cs.depaul.edu>

Pynthon

unread,
Nov 24, 2009, 12:17:20 PM11/24/09
to web2py-users
Ah, OK thanks for the info Massimo. You know last week I was thinking
about web2py. Well not about web2py but about a web-framework in
python for GAE. I know w2p supports GAE but I mean a framework that
only runs on GAE. A framework build on top of the GAE framework. I
think it could be really popular, do you know some people who are
starting a project like this or does someone who is reading this have
interests? The problem is that I have not enough knowledge about
Python, GAE or web-development. Anyway, I just think it is dream :p.

Thanks

Richard

unread,
Nov 25, 2009, 1:00:07 AM11/25/09
to web2py-users
if you want something simple for GAE just use the built in webapp
framework from Google:
http://code.google.com/appengine/docs/python/tools/webapp/

David

unread,
Nov 25, 2009, 7:24:48 AM11/25/09
to web2py-users
Thanks Massimo! I used the updated code and all is well.
Reply all
Reply to author
Forward
0 new messages