Forums

web2py - invalid view

I just upgraded web2py to Version 2.9.5-stable+timestamp.2014.03.16.02.35.39

Trying to call http://einstein.pythonanywhere.com/xxx/default/fragen results in "invalid view (default/fragen.html)", downloadin web2py and running it locally (mac os x 10.9.2) delivers the expected crud form.

This is the controller:

1
2
3
def fragen():
    grid = SQLFORM.smartgrid(db.Fragenliste,user_signature=False) 
    return locals()

what is going wrong ? kind regards Sven

first solution: must enable generic views for non local access in models/db.py (see http://web2py.com/books/default/chapter/29/10#Generic-views)

But still no change !

OK got It: cleaned teh app, deleted bytecode and now it works ;)

Excellent, glad it's working now :-)

me too ;)

and thank you for this great platform !!!

You're welcome :-)

index.html

{{if auth.user:}}
{{=A('create new survey',_href=URL('create_survey'),_class="btn btn-primary")}}
{{=grid}}
{{else:}}
Welcome to this survey app, login or register to create a survey
{{pass}}

default.html

def create_survey():
    def f(form):
        form.vars.results = [0]*len(request.vars.choices)
    from gluon.utils import web2py_uuid
    db.survey.uuid.default = uuid = web2py_uuid()
    form = SQLFORM(db.survey).process(onvalidation=f)
    if form.accepted:
        redirect(URL('take_survey',args=uuid))
    return locals()

def take_survey():
    uuid = request.args(0)
    survey = db.survey(uuid=uuid) or redirect(URL('index'))
    if survey.requires_login:
        if not auth.user:
             redirect(URL('user/login',vars=dict(_next=URL(args=uuid))))
        vote = db.vote(survey=survey.id,created_by=auth.user.id)
        if vote:
             session.flash = 'You voted already!'
             redirect(URL('thank_you'))
    if request.post_vars:
         k = int(request.post_vars.choice)
         survey.results[k]+=1
         survey.update_record(results=survey.results)
         if survey.requires_login:
             db.vote.insert(survey=survey.id)
         redirect(URL('thank_you'))
    return locals()

in local its working properly...tested this code in "pythonanywhere.com" site ..its not working..got below error

invalid view (default/create_survey.html)

how to solve this issue?any one can you help me....

[edit by admin: code formatting]

That's probably a question best asked on the web2py users Google Group.