anchor tags in python
Hello, I was wondering how to pass a page anchor in a python script... My script: ---------- import string import types form=context.REQUEST.form # do some processing, etc... # return the birds page at the anchor (how???) joint = container['birds'] return joint() birds html file: ---------------- <HTML> <BODY> ..... <A NAME="birdsong">Bird song</A> blah blah blah.... ..... </HTML> I want to have the page center at the "birdsong" in the file... any ideas how to do this? Please include me in the reply, as I am not on this list. Thanks in advance, Daniel
On Thu, May 08, 2003 at 02:30:31PM -0400, Daniel Tang wrote:
Hello,
I was wondering how to pass a page anchor in a python script...
My script: ---------- import string import types
form=context.REQUEST.form
# do some processing, etc...
# return the birds page at the anchor (how???)
joint = container['birds'] return joint()
why call it? you could redirect instead. e.g. response = context.REQUEST.RESPONSE anchor_name = 'bird_song' # or this could be dynamically generated response.redirect('%s#%s' % (container['birds'].absolute_url(), anchor_name)) -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
On Thu, 8 May 2003, Paul Winkler wrote:
On Thu, May 08, 2003 at 02:30:31PM -0400, Daniel Tang wrote:
Hello,
I was wondering how to pass a page anchor in a python script...
My script: ---------- import string import types
form=context.REQUEST.form
# do some processing, etc...
# return the birds page at the anchor (how???)
joint = container['birds'] return joint()
why call it? you could redirect instead. e.g.
Thanks for the help... If I had some variables, how would i pass those along in a redirect? joint = container['birds'] return joint(var=var, var2="robin", var3="cardinal") --Daniel
response = context.REQUEST.RESPONSE anchor_name = 'bird_song' # or this could be dynamically generated response.redirect('%s#%s' % (container['birds'].absolute_url(), anchor_name))
--
Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Thu, May 08, 2003 at 02:54:17PM -0400, Daniel Tang wrote:
If I had some variables, how would i pass those along in a redirect?
joint = container['birds'] return joint(var=var, var2="robin", var3="cardinal")
you could add them to the query string: from ZTUtils import make_query args = make_query(var=var, var2="robin", var3="cardinal") url = "where/to/go?" + args response.redirect(url) This should work but personally i've wished there was a way to take a request object (modified arbitrarily) and send it along with a redirect. so you could use POST and not put gunk in the URL. but zope doesn't provide for that, and while I haven't looked into it, i suspect that HTTP redirect does not support such things. -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
I was wondering how to pass a page anchor in a python script...
My script: ---------- import string import types
form=context.REQUEST.form
# do some processing, etc...
# return the birds page at the anchor (how???)
joint = container['birds'] return joint()
Build a URL for the anchor and page and the use REQUEST.RESPONSE.redirect(url) to go there. You should probably be paranoid and use absolute_url on the page and the Python Scripts url quoting function on the anchor, though you could just say anchor = 'birdsong' # or whatever url = 'birds#' + anchor --jcc
Hi Daniel. I'm not quite sure what you're asking, but I think that a redirect might do what you want: context.REQUEST.RESPONSE.redirect(container['birds'].absolute_url() + '#birdsong') Daniel Tang wrote:
Hello,
I was wondering how to pass a page anchor in a python script...
My script: ---------- import string import types
form=context.REQUEST.form
# do some processing, etc...
# return the birds page at the anchor (how???)
joint = container['birds'] return joint()
birds html file: ---------------- <HTML> <BODY>
.....
<A NAME="birdsong">Bird song</A>
blah blah blah....
.....
</HTML>
I want to have the page center at the "birdsong" in the file... any ideas how to do this?
Please include me in the reply, as I am not on this list.
Thanks in advance, Daniel
participants (4)
-
Daniel Tang -
J Cameron Cooper -
Paul Winkler -
Troy Farrell