I tried this:

        self.response.out.write("<ol>")
        for item in items:
            self.response.out.write("""<li><a href="%s">%s</a><br />
<a href="/item?%s">comments</a></li> """ %
                                    (cgi.escape(item.url),
cgi.escape(item.title), cgi.escape(item.key().id())))
        self.response.out.write("</ol>")

but gives this error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine
\ext\webapp\__init__.py", line 515, in __call__
    handler.get(*groups)
  File "C:\sarah.py", line 37, in get
    (cgi.escape(item.url), cgi.escape(item.title),
cgi.escape(item.key().id())))
  File "C:\Python26\lib\cgi.py", line 1023, in escape
    s = s.replace("&", "&amp;") # Must be done first!
AttributeError: 'long' object has no attribute 'replace'

Can anyone help?


On Jan 14, 9:10 pm, Zeynel <[email protected]> wrote:
> I figured that
>
>         i_id = item.key().id()
>
>         logging.info("i_id is: %s" % item.key().id())
>
> gets the id number. Can anyone help about forming the corresponding
> url?
>
> Thanks.
>
> On Jan 14, 7:38 pm, Zeynel <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I am working on a simple news site for people to post Sarah Palin
> > related links. At this point I have a submit 
> > pagehttp://sarah-for-president.appspot.com/submitanda newest 
> > pagehttp://sarah-for-president.appspot.com/newest
>
> > But I also want to add a comments page (like in Hacker News) so that
> > people can comment on each article. I want to use disqus for comments
> > and the page will look something like 
> > thishttp://sarah-for-president.appspot.com/comments
>
> > But I don't understand how I can connect an article with its comments.
> > Hacker News has urls of this typehttp://news.ycombinator.com/item?id=2105038
>
> > I see in Datastore Viewer that each entry has an id:
>
> > ID/Name: id=1
> > date: 2011-01-14 20:51:28.256421
> > title: Sarah Palin Wikipedia page
> > url:http://en.wikipedia.org/wiki/Sarah_Palin
>
> > Can you help me understand how to form the urls of the 
> > formhttp://sarah-for-president.appspot.com/item?id=1
>
> > Or if this is not correct, what is the correct way?
>
> > This is my app.yaml:
>
> > application: sarah-for-president
> > version: 1
> > runtime: python
> > api_version: 1
>
> > handlers:
> > - url: /favicon.ico
> >   static_files: static/images/favicon.ico
> >   upload: static/images/favicon.ico
>
> > - url: /.*
> >   script: sarah.py
>
> > inbound_services:
> > - mail
>
> > and the code is here:http://pastebin.com/5bnEURhj
>
> > (sorry for all the HTML, i am not using templating at this point)
>
> > Thanks!

-- 
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.

Reply via email to