i've included my custom url_for() function below.
since the point of the custom domain mappings is to 'hide' a
controller from the URL, the function exploits this when rewriting
urls returned by h.url_for().
if the request_uri string contains a reference to the controller, then
we are not using the custom domain mapping and we don't need to mangle
h.url_for()'s results. however, if it is missing, then we are using a
custom domain that hides the path to the controller, and we need to
make sure h.url_for() does not include a reference to it.
i still need some fine tuning (edge cases, or if i decide to hide a
controller+action from the url), but i seem to be on the right track
with this
def url_for(*p, **k):
url = h.url_for(*p, **k)
path =
request.environ['REQUEST_URI'].replace(request.environ['QUERY_STRING'],
'')
cont = request.environ.get('pylons.routes_dict').get('controller')
if path.find(cont) != -1:
return url
else:
return re.sub('^/' + cont + '/?', '/', url)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---