I had to use another generic-edit template as some views were not compatible with the previous implementation of generic-edit.
Also, since the POTemplate admin page can rename the template name, I had to implement this dirty hack in order to avoid redirecting to a page that is no longer available.
I asked Curtis, and he agree that this is not a clean solution but he also said the code is correct and he is not aware of any other better solution.
Any suggestion is much appreciated.
Can you please review the changes?
Here is the new diff.
@property
def next_url(self):
@@ -548,6 +551,13 @@
referrer = self.request.form.get('next_url')
if referrer is None: referrer = self.request.getHeader('referer')
+ if (referrer is None
+ or canonical_url(self.context) in referrer):
+ # XXX: AdiRoiban 2010-02-32
+ # Since 'referer' can depend on the object name, and
+ # from this form we can rename the object I was forced
+ # to use this dirty hack.
+ return "DIRTY_HACK"
if (referrer is not None
and referrer.startswith(self.request.getApplicationURL())
Hi Graham,
I had to use another generic-edit template as some views were not compatible with the previous implementation of generic-edit.
Also, since the POTemplate admin page can rename the template name, I had to implement this dirty hack in order to avoid redirecting to a page that is no longer available.
I asked Curtis, and he agree that this is not a clean solution but he also said the code is correct and he is not aware of any other better solution.
Any suggestion is much appreciated.
Can you please review the changes?
Here is the new diff.
=== added file 'lib/lp/ app/templates/ generic- edit-next- url.pt' app/templates/ generic- edit-next- url.pt 1970-01-01 00:00:00 +0000 app/templates/ generic- edit-next- url.pt 2010-02-22 22:44:11 +0000 www.w3. org/1999/ xhtml" xml.zope. org/namespaces/ tal" xml.zope. org/namespaces/ metal" xml.zope. org/namespaces/ i18n" macro=" view/macro: page/main_ only" "launchpad" > slot="main" > macro=" context/ @@launchpad_ form/form" > slot="extra_ info"> "view/next_ url" "value view/next_url" />
--- lib/lp/
+++ lib/lp/
@@ -0,0 +1,19 @@
+<html
+ xmlns="http://
+ xmlns:tal="http://
+ xmlns:metal="http://
+ xmlns:i18n="http://
+ metal:use-
+ i18n:domain=
+ <body>
+ <div metal:fill-
+ <div metal:use-
+ <div metal:fill-
+ <input type="hidden" name="next_url"
+ tal:condition=
+ tal:attributes=
+ </div>
+ </div>
+ </div>
+ </body>
+</html>
=== modified file 'lib/lp/ app/templates/ generic- edit.pt' app/templates/ generic- edit.pt 2010-02-16 12:15:12 +0000 app/templates/ generic- edit.pt 2010-02-22 22:43:37 +0000 domain= "launchpad" > slot="main" > macro=" context/ @@launchpad_ form/form" > slot="extra_ info"> "view/next_ url" "value view/next_url" /> macro=" context/ @@launchpad_ form/form" />
--- lib/lp/
+++ lib/lp/
@@ -7,13 +7,7 @@
i18n:
<body>
<div metal:fill-
- <div metal:use-
- <div metal:fill-
- <input type="hidden" name="next_url"
- tal:condition=
- tal:attributes=
- </div>
- </div>
+ <div metal:use-
</div>
</body>
</html>
=== modified file 'lib/lp/ translations/ browser/ configure. zcml' translations/ browser/ configure. zcml 2010-02-10 13:04:10 +0000 translations/ browser/ configure. zcml 2010-02-22 22:47:03 +0000
for= "lp.translation s.interfaces. potemplate. IPOTemplate"
class= "lp.translation s.browser. potemplate. POTemplateEditV iew"
permissio n="launchpad. Edit" "../../ app/templates/ generic- edit.pt" "../../ app/templates/ generic- edit-next- url.pt"
layer= "canonical. launchpad. layers. TranslationsLay er"/>
<browser: page
name= "+admin"
for= "lp.translation s.interfaces. potemplate. IPOTemplate"
class= "lp.translation s.browser. potemplate. POTemplateAdmin View"
permissio n="launchpad. TranslationsAdm in" "../../ app/templates/ generic- edit.pt" "../../ app/templates/ generic- edit-next- url.pt"
layer= "canonical. launchpad. layers. TranslationsLay er"/>
<browser: page
name= "+export"
--- lib/lp/
+++ lib/lp/
@@ -414,14 +414,14 @@
- template=
+ template=
- template=
+ template=
=== modified file 'lib/lp/ translations/ browser/ potemplate. py' translations/ browser/ potemplate. py 2010-02-16 12:15:12 +0000 translations/ browser/ potemplate. py 2010-02-23 15:27:27 +0000
--- lib/lp/
+++ lib/lp/
@@ -538,7 +538,10 @@
@property url(self. context)
def cancel_url(self):
- return self.next_url
+ if self.next_url == "DIRTY_HACK":
+ return canonical_
+ else:
+ return self.next_url
@property form.get( 'next_url' )
referrer = self.request. getHeader( 'referer' ) url(self. context) in referrer):
def next_url(self):
@@ -548,6 +551,13 @@
referrer = self.request.
if referrer is None:
+ if (referrer is None
+ or canonical_
+ # XXX: AdiRoiban 2010-02-32
+ # Since 'referer' can depend on the object name, and
+ # from this form we can rename the object I was forced
+ # to use this dirty hack.
+ return "DIRTY_HACK"
if (referrer is not None startswith( self.request. getApplicationU RL())
and referrer.