My paging attempts following these jcgregorio links are not quite
working. The problem seems to be using the created and now variables.
I continue to get error messages that complain about my variable
name "created" (and sometime with my variable named "now"). The
error (line 495) refers to the code below, immediately before the
"s.put()" in which the time properties of s are updated. The messages
look like this:
*********************error message excerpted below***********
File "/Users/brian/googleapps/simplifyconnections/mainapp.py", line
495, in post
created = now)
BadValueError: Property category must be an int or long, not a str
*********************error message excerpted above***********
My application does not require users to have google accounts, and I
am not worried about high usage levels that would make two suggestions
simultaneous, so I am just wanting to use the timestamp as the
sequencing variable. So my function "whenfromcreated", while patterned
after Gregorio's, is simpler. My code in theory is even simpler than
Joe Gregorio's. Let me see if I can put in the relevant code below.
*********************code excerpted below***********
from datetime import datetime
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
from google.appengine.ext import db
PAGESIZE = 10
class Log(db.Model):
comment = db.StringProperty()
name = db.StringProperty()
category = db.IntegerProperty(default=0)
pinlabel = db.StringProperty()
when = db.StringProperty()
created = db.DateTimeProperty(auto_now_add=True)
def whenfromcreated(created):
return created.isoformat()[0:19]
####This handler was made possible by an Article by Joe Gregorio
#### and by his code at the following link
####
http://code.google.com/p/google-app-engine-samples/source/browse/#svn/trunk/paging
class DetailsLog(webapp.RequestHandler):
def get(self):
logging.info("Get ")
bookmark = self.request.get("bookmark")
next = None
if bookmark:
query = Log.gql('WHERE when <= :bookmark ORDER BY when DESC',
bookmark=bookmark)
comments = query.fetch(PAGESIZE+1)
else:
comments = Log.gql('ORDER BY when DESC').fetch(PAGESIZE+1)
if len(comments) == PAGESIZE+1:
next = comments[-1].when
comments = comments[:PAGESIZE]
chtml = captcha.displayhtml(
public_key = "6LduxwQAAAAAAPYWf4El7VvMucyolt6GLbv1Fmpe",
use_ssl = False,
error = None)
template_values = {'next': next, 'comments': comments,
'captchahtml':
chtml}
#template_values = {'next': next} # to initialize use this one
template_file = os.path.join(os.path.dirname(__file__),
'log.html')
self.response.out.write(template.render(template_file,
template_values))
def post(self):
challenge = self.request.get('recaptcha_challenge_field')
response = self.request.get('recaptcha_response_field')
remoteip = self.request.remote_addr
cResponse = captcha.submit(
challenge,
response,
"privatekey",
remoteip)
if cResponse.is_valid:
now = datetime.now()
when = whenfromcreated(now)
s = Log(
comment = self.request.get('comment'),
category = self.request.get('category'),
name = self.request.get('name'),
pinlabel = self.request.get('pinlabel'),
when = when,
created = now)
s.put()
self.redirect('/comment')
else:
chtml = captcha.displayhtml(
public_key = "6LduxwQAAAAAAPYWf4El7VvMucyolt6GLbv1Fmpe",
use_ssl = False,
error = cResponse.error_code)
self.response.out.write("An error occurred with the
reCaptcha")
self.redirect('/comment')
*********************code excerpted above***********
On Jan 26, 9:54 am, Marzia Niccolai <[email protected]> wrote:
> Hi,
>
> There are a couple of reliable ways to dopagingwith App Engine for
> arbitrarily sized data sets, both of which are discussed in this
> article:http://code.google.com/appengine/articles/paging.html
> And the corresponding sample
> code:http://code.google.com/p/google-app-engine-samples/source/browse/#svn...
>
> The easiest way is to just use keypaging, if key ordering is
> sufficient for yourpagingneeds.
>
Brian in Atlanta
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---