merge stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 10 Nov 2009 18:13:07 +0100
branchstable
changeset 3817 9fcf048e14b7
parent 3816 37b376bb4088 (diff)
parent 3815 50b87f759b5d (current diff)
child 3818 9522e51d8644
merge
--- a/web/request.py	Tue Nov 10 18:06:47 2009 +0100
+++ b/web/request.py	Tue Nov 10 18:13:07 2009 +0100
@@ -25,7 +25,7 @@
 from cubicweb.dbapi import DBAPIRequest
 from cubicweb.common.mail import header
 from cubicweb.common.uilib import remove_html_tags
-from cubicweb.utils import SizeConstrainedList, HTMLHead
+from cubicweb.utils import SizeConstrainedList, HTMLHead, make_uid
 from cubicweb.view import STRICT_DOCTYPE, TRANSITIONAL_DOCTYPE_NOEXT
 from cubicweb.web import (INTERNAL_FIELD_VALUE, LOGGER, NothingToEdit,
                           RequestError, StatusResponse)
@@ -83,10 +83,20 @@
         # tabindex generator
         self.tabindexgen = count(1)
         self.next_tabindex = self.tabindexgen.next
-        # page id, set by htmlheader template
-        self.pageid = None
         self.varmaker = rqlvar_maker()
         self.datadir_url = self._datadir_url()
+        self._set_pageid()
+
+    def _set_pageid(self):
+        """initialize self.pageid
+        if req.form provides a specific pageid, use it, otherwise build a
+        new one.
+        """
+        pid = self.form.get('pageid')
+        if pid is None:
+            pid = make_uid(id(self))
+        self.pageid = pid
+        self.html_headers.define_var('pageid', pid)
 
     def set_connection(self, cnx, user=None):
         """method called by the session handler when the user is authenticated
--- a/web/views/basecontrollers.py	Tue Nov 10 18:06:47 2009 +0100
+++ b/web/views/basecontrollers.py	Tue Nov 10 18:13:07 2009 +0100
@@ -250,7 +250,6 @@
         response content type
         """
         self.req.json_request = True
-        self.req.pageid = self.req.form.get('pageid')
         try:
             fname = self.req.form['fname']
             func = getattr(self, 'js_%s' % fname)
--- a/web/views/basetemplates.py	Tue Nov 10 18:06:47 2009 +0100
+++ b/web/views/basetemplates.py	Tue Nov 10 18:13:07 2009 +0100
@@ -13,7 +13,7 @@
 from cubicweb.appobject import objectify_selector
 from cubicweb.selectors import match_kwargs
 from cubicweb.view import View, MainTemplate, NOINDEX, NOFOLLOW
-from cubicweb.utils import make_uid, UStringIO, can_do_pdf_conversion
+from cubicweb.utils import UStringIO, can_do_pdf_conversion
 from cubicweb.schema import display_name
 
 # main templates ##############################################################
@@ -316,7 +316,6 @@
         self.stylesheets()
         self.javascripts()
         self.alternates()
-        self.pageid()
 
     def favicon(self):
         favicon = self.req.external_resource('FAVICON', None)
@@ -344,12 +343,6 @@
             self.whead(u'<link rel="alternate" type="application/rss+xml" title="RSS feed" href="%s"/>\n'
                        %  xml_escape(urlgetter.feed_url()))
 
-    def pageid(self):
-        req = self.req
-        pid = make_uid(id(req))
-        req.pageid = pid
-        req.html_headers.define_var('pageid', pid)
-
 
 class HTMLPageHeader(View):
     """default html page header"""