Hi, I'm pretty new to python / the google app engine, and I'm currently
working on the online part of a desktop app I wrote.
One of the features is an image uploader, thats uses the Imgur API, and I
would like to record every produced Imgur url into the datastore,
to create a giant mashup later with the python image processing library.
For example "ZCFc1", in the url http://imgur.com/ZCFc1
I'm testing with the following code (with an input like "?newlink=ZCFc1")
class Links(db.Model):
> link = db.StringProperty()
>
> class MainPage(webapp2.RequestHandler):
> def get(self):
> addlink = self.request.get('newlink')
> self.response.headers['Content-Type'] = 'text/plain'
> self.response.out.write(addlink)
> Links(link = addlink).put()
>
Each entry is recorded correctly as "link" of the "Links" class,
but now I need to retrieve all of these links, and I still couldn't find a
way to do that.
The documentation is mainly focused on reading a specific entry for a
specific class,
but doesn't give much help with more global approaches.
I tried the following code, but it would only print something like
"<google.appengine.ext.db.Query object at 0x030D3390>"
instead of returning the actual contents
class Links(db.Model):
> link = db.StringProperty()
>
> class MainPage(webapp2.RequestHandler):
> def get(self):
> linklist = Links.all()
> self.response.headers['Content-Type'] = 'text/plain'
> self.response.out.write(linklist)
>
I saw the fetch() command, but how could I tell how many entries I need to
retrieve in that case?
Also I thought of using a StringListProperty instead for a single list of
links, but I would have to read and overwrite it each time,
and it doesn't seems as handy and reliable as having a separate entry for
each link?
Thx for your help,
Lemo
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-appengine/-/G_Mq6uR0lX8J.
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.