J
Jens
Hello Everyone
I'm newbie to Zope and i have a few questions regarding external
methods. What i wan't to do
is provide a terse syntax for converting urls to special tracking
urls:
<dtml-var "track('http://myurl/')">
turns the provided url into something like
http://host/tracking?url=http://myurl/
in the output.
i've been trying to use a external procedure like this.
## Script (Python) "track_link"
##bind container=container
##bind context=context
##bind namespace=_
##bind script=script
##bind subpath=traverse_subpath
##parameters=self,url
##title=track link
##
return "%s%s" % (self.tracking_prefix, url_quote(url))
This doesn't work because because the method doesn't have access to
the environment. Obviously I don't wan't to pass everything explicitly
into the function as this would defeat the purpose of the exercise,
namely to provide a terse syntax.
I have a background in other languages so I might be missing something
conceptually with regard Zope and DTML.. Is there a better was of
doing this, perhaps without using external methods? Currently im doing
the following which isn't very elegant:
in content document
<a href="<dtml-let exturl="'http://www.mylink.com/"><dtml-var
tracking></dtml-let>">link</a>
....
tracking:
<dtml-var tracking_prefix><dtml-var name="exturl" url_quote_plus>
Appreciate any input you might have on this-
I'm newbie to Zope and i have a few questions regarding external
methods. What i wan't to do
is provide a terse syntax for converting urls to special tracking
urls:
<dtml-var "track('http://myurl/')">
turns the provided url into something like
http://host/tracking?url=http://myurl/
in the output.
i've been trying to use a external procedure like this.
## Script (Python) "track_link"
##bind container=container
##bind context=context
##bind namespace=_
##bind script=script
##bind subpath=traverse_subpath
##parameters=self,url
##title=track link
##
return "%s%s" % (self.tracking_prefix, url_quote(url))
This doesn't work because because the method doesn't have access to
the environment. Obviously I don't wan't to pass everything explicitly
into the function as this would defeat the purpose of the exercise,
namely to provide a terse syntax.
I have a background in other languages so I might be missing something
conceptually with regard Zope and DTML.. Is there a better was of
doing this, perhaps without using external methods? Currently im doing
the following which isn't very elegant:
in content document
<a href="<dtml-let exturl="'http://www.mylink.com/"><dtml-var
tracking></dtml-let>">link</a>
....
tracking:
<dtml-var tracking_prefix><dtml-var name="exturl" url_quote_plus>
Appreciate any input you might have on this-