as an aside,  wiki.web2py.com seems to be stuck generating tickets...

On Mar 5, 8:14 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> change this
>    selected_choice.update_record(votes=db.choice.votes+1)
>  into
>    selected_choice.update_record(votes=seleted_choice.votes+1)
>
> Mind that I tried to code the original Django app so that it would
> make the original SQL queries. That is way it does not work on GAE.
>
> On Mar 5, 12:58 am, mdmcginn <michael.d.mcgin...@gmail.com> wrote:
>
> > Thanks. Now the pages display successfully that show the poll results
> > and the voting options:http://localhost:8080/Polls/default/detail/9
> > andhttp://localhost:8080/Polls/default/results/9.
> > But when I voted, I got errors 
> > withhttp://localhost:8080/Polls/default/detail/9
> > - my vote wasn't saved. The error said, "non supported on GAE."
>
> > (I should say that I have two web2py applications deployed at once on
> > my local GAE environment: the original Polls and my own variation on
> > it which adds forms for adding poll questions and voting choices. So
> > that's how I'm adding question and choice records for Polls. I could
> > imagine that having two applications using the same tables could be a
> > problem.)
>
> > -------
>
> > Controller:
> > @auth.requires_login()
> > def detail():
> >     poll_id=request.args(0)
> >     p = db.poll[poll_id]
> >     if not p: raise HTTP(404)
> > # Has this person allready voted???
> >     if db(db.recorded_votes.poll==p.id)
> > (db.recorded_votes.voter==auth.user.id).select():
> >         session.flash="You have already voted on this question"
> >         redirect(URL(r=request,f='results',args=p.id))
> > # add this
> >     if request.vars:
> >         selected_choice = db.choice[request.vars.choice]
> >         if not selected_choice or selected_choice.poll!=p.id:
> >             session.flash="Please select a valid choice"
> >             redirect(URL(r=request,f='detail',args=p.id))
> >         else:
> >             selected_choice.update_record(votes=db.choice.votes+1)
> > # add the following line after adjusting the detail view below
>
> > db.recorded_votes.insert(voter=auth.user.id,poll=p.id)
> >             redirect(URL(r=request,f='results',args=p.id))
> >     return dict(poll=p)
>
> > --------
>
> > Traceback (most recent call last):
> >   File "/home/michael/mycode/google_appengine/web2py/gluon/
> > restricted.py", line 173, in restricted
> >     exec ccode in environment
> >   File "/home/michael/mycode/google_appengine/web2py/applications/
> > Polls/controllers/default.py:detail", line 93, in <module>
> >   File "/home/michael/mycode/google_appengine/web2py/gluon/
> > globals.py", line 96, in <lambda>
> >     self._caller = lambda f: f()
> >   File "/home/michael/mycode/google_appengine/web2py/gluon/tools.py",
> > line 1850, in f
> >     return action(*a, **b)
> >   File "/home/michael/mycode/google_appengine/web2py/applications/
> > Polls/controllers/default.py:detail", line 32, in detail
> >   File "/home/michael/mycode/google_appengine/web2py/gluon/sql.py",
> > line 3145, in <lambda>
> >     i = id, **a: update_record(c, t, i, a)
> >   File "/home/michael/mycode/google_appengine/web2py/gluon/sql.py",
> > line 3268, in update_record
> >     table._db(table.id==id).update(**c)
> >   File "/home/michael/mycode/google_appengine/web2py/gluon/contrib/
> > gql.py", line 718, in update
> >     table[field].type, db)
> >   File "/home/michael/mycode/google_appengine/web2py/gluon/contrib/
> > gql.py", line 440, in obj_represent
> >     raise SyntaxError, "non supported on GAE"
> > SyntaxError: non supported on GAE
>
> > On Mar 4, 1:13 am, "mr.freeze" <nat...@freezable.com> wrote:
>
> > > I think the problems is that poll doesn't have a foreign key to
> > > choice, it's the other way around. Try this:
> > > {{poll_choices = db(db.choice.poll==poll.id).select()}}
> > > {{ for choice in poll_choices: }}
> > >     <li>{{=choice.choice }} -- {{=choice.votes }} vote{{if
> > > choice.votes!=1:}}s{{pass}}</li>
> > > {{ pass }
>
> > > On Mar 3, 11:51 pm, mdmcginn <michael.d.mcgin...@gmail.com> wrote:
>
> > > > db.define_table('poll',
> > > >         Field('question',length=200),
>
> > > > Field('pub_date','datetime',default=request.now,writable=False))
>
> > > > db.define_table('choice',
> > > >         Field('poll',db.poll),
> > > >         Field('choice',length=200),
> > > >         Field('votes','integer',default=0))
>
> > > > db.define_table('recorded_votes',
> > > >     Field('poll',db.poll),
> > > >     Field('voter',db.auth_user))
>
> > > > On Mar 1, 9:37 pm, "mr.freeze" <nat...@freezable.com> wrote:
>
> > > > > Can we see your model?
>
> > > > > On Mar 1, 9:05 pm, mdmcginn <michael.d.mcgin...@gmail.com> wrote:
>
> > > > > > From index.html:
> > > > > > Latest Polls
> > > > > > Answer the question [vote] [results]
>
> > > > > > When I click on [results], I'm sent 
> > > > > > tohttp://localhost:8080/Polls/default/results/67
>
> > > > > > ERROR    2010-03-02 02:54:08,609 restricted.py:53] In FILE: /home/
> > > > > > michael/mycode/google_appengine/web2py/applications/Polls/views/
> > > > > > default/results.html
>
> > > > > > Traceback (most recent call last):
> > > > > >   File "/home/michael/mycode/web2py/gluon/restricted.py", line 173, 
> > > > > > in
> > > > > > restricted
> > > > > >     exec ccode in environment
> > > > > >   File "/home/michael/mycode/google_appengine/web2py/applications/
> > > > > > Polls/views/default/results.html", line 64, in <module>
> > > > > >   File "/home/michael/mycode/web2py/gluon/sql.py", line 3041, in
> > > > > > select
> > > > > >     query = self._select(*fields, **attributes)
> > > > > >   File "/home/michael/mycode/web2py/gluon/sql.py", line 2932, in
> > > > > > _select
> > > > > >     raise SyntaxError, 'Set: no tables selected'
> > > > > > SyntaxError: Set: no tables selected
>
> > > > > > INFO     2010-03-02 02:54:08,610 gaehandler.py:55] **** Request:
> > > > > > 286.06ms/50.00ms (real time/cpu time)
> > > > > > INFO     2010-03-02 02:54:08,618 dev_appserver.py:3246] "GET /Polls/
> > > > > > default/results/67 HTTP/1.1" 500 -
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to