backport changesets which should have been in stable branch. now *stable is 3.3* and *default is 3.4* stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Jun 2009 10:40:54 +0200
branchstable
changeset 2052 0b9b0bdc93f5
parent 2041 296e897ab8e1 (current diff)
parent 2051 e4d24e4d74e6 (diff)
child 2053 fb156d69bfd9
backport changesets which should have been in stable branch. now *stable is 3.3* and *default is 3.4*
web/views/management.py
--- a/doc/book/en/annexes/rql/language.rst	Thu Jun 04 20:21:40 2009 +0200
+++ b/doc/book/en/annexes/rql/language.rst	Fri Jun 05 10:40:54 2009 +0200
@@ -299,7 +299,7 @@
 
 
   Note: You can not specify several types with * ... where X is FirstType or X is SecondType*.
-  To specify several types explicitely, you have to do
+  To specify several types explicitly, you have to do
 
   ::
 
--- a/doc/book/en/development/devcore/vreg.rst	Thu Jun 04 20:21:40 2009 +0200
+++ b/doc/book/en/development/devcore/vreg.rst	Fri Jun 05 10:40:54 2009 +0200
@@ -13,7 +13,10 @@
   conditionnellement,
   - enregistrement explicite en définissant la fonction `registration_callback(vreg)`
   - appel des méthodes d'enregistrement des objets sur le vreg
-
+.. note::
+    Once the function `registration_callback(vreg)` is implemented, all the objects
+    need to be explicitly registered as it disables the automatic object registering.
+    
 * suppression de l'ancien système quand il ne restera plus de réference au
   module registerers dans le code des cubes existants.
 
@@ -148,4 +151,4 @@
 
 Debugging
 `````````
-XXX explain traced_selection context manager
\ No newline at end of file
+XXX explain traced_selection context manager
--- a/doc/book/en/development/webstdlib/boxes.rst	Thu Jun 04 20:21:40 2009 +0200
+++ b/doc/book/en/development/webstdlib/boxes.rst	Fri Jun 05 10:40:54 2009 +0200
@@ -12,7 +12,7 @@
 an entity automatically related to the initial entity (context in
 which the box is displayed). By default, the links generated in this
 box are computed from the schema properties of the displayed entity,
-but it is possible to explicitely specify them thanks to the
+but it is possible to explicitly specify them thanks to the
 `cubicweb.web.uicfg.rmode` *relation tag*:
 
 * `link`, indicates that a relation is in general created pointing
--- a/server/schemaserial.py	Thu Jun 04 20:21:40 2009 +0200
+++ b/server/schemaserial.py	Fri Jun 05 10:40:54 2009 +0200
@@ -83,6 +83,9 @@
                 sqlcu.execute(sql)
 
 # schema / perms deserialization ##############################################
+OLD_SCHEMA_TYPES = frozenset(('EFRDef', 'ENFRDef', 'ERType', 'EEType',
+                              'EConstraintType', 'EConstraint', 'EGroup',
+                              'EUser', 'ECache', 'EPermission', 'EProperty'))
 
 def deserialize_schema(schema, session):
     """return a schema according to information stored in an rql database
@@ -92,16 +95,15 @@
     repo = session.repo
     sqlcu = session.pool['system']
     _3_2_migration = False
-    tables = set(t.lower() for t in repo.system_source.dbhelper.list_tables(sqlcu))
+    dbhelper = repo.system_source.dbhelper
+    tables = set(t.lower() for t in dbhelper.list_tables(sqlcu))
     if 'eetype' in tables:
         _3_2_migration = True
         # 3.2 migration
         _set_sql_prefix('')
         # first rename entity types whose name changed in 3.2 without adding the
         # cw_ prefix
-        for etype in ('EFRDef', 'ENFRDef', 'ERType', 'EEType',
-                      'EConstraintType', 'EConstraint', 'EGroup', 'EUser',
-                      'ECache', 'EPermission', 'EProperty'):
+        for etype in OLD_SCHEMA_TYPES:
             if etype.lower() in tables:
                 sql = 'ALTER TABLE %s RENAME TO %s' % (etype,
                                                        ETYPE_NAME_MAP[etype])
@@ -123,18 +125,25 @@
             eschema.eid = eid
             index[eid] = eschema
             continue
-        if etype in ETYPE_NAME_MAP: # XXX <2.45 bw compat
-            print 'fixing etype name from %s to %s' % (etype, ETYPE_NAME_MAP[etype])
+        if etype in ETYPE_NAME_MAP:
+            netype = ETYPE_NAME_MAP[etype]
+            print 'fixing etype name from %s to %s' % (etype, netype)
             # can't use write rql queries at this point, use raw sql
             session.system_sql('UPDATE %(p)sCWEType SET %(p)sname=%%(n)s WHERE %(p)seid=%%(x)s'
                                % {'p': sqlutils.SQL_PREFIX},
-                               {'x': eid, 'n': ETYPE_NAME_MAP[etype]})
+                               {'x': eid, 'n': netype})
             session.system_sql('UPDATE entities SET type=%(n)s WHERE type=%(x)s',
-                               {'x': etype, 'n': ETYPE_NAME_MAP[etype]})
+                               {'x': etype, 'n': netype})
+            # XXX should be donne as well on sqlite based sources
+            if not etype in OLD_SCHEMA_TYPES and \
+               (getattr(dbhelper, 'case_sensitive', False) 
+                or etype.lower() != netype.lower()):
+                session.system_sql('ALTER TABLE %s%s RENAME TO %s%s' % (
+                    sqlutils.SQL_PREFIX, etype, sqlutils.SQL_PREFIX, netype))
             session.commit(False)
             try:
                 session.system_sql('UPDATE deleted_entities SET type=%(n)s WHERE type=%(x)s',
-                                   {'x': etype, 'n': ETYPE_NAME_MAP[etype]})
+                                   {'x': etype, 'n': netype})
             except:
                 pass
             tocleanup = [eid]
@@ -142,7 +151,7 @@
                           if etype == eidetype)
             repo.clear_caches(tocleanup)
             session.commit(False)
-            etype = ETYPE_NAME_MAP[etype]
+            etype = netype
         etype = ybo.EntityType(name=etype, description=desc, meta=meta, eid=eid)
         eschema = schema.add_entity_type(etype)
         index[eid] = eschema
--- a/web/views/basecontrollers.py	Thu Jun 04 20:21:40 2009 +0200
+++ b/web/views/basecontrollers.py	Fri Jun 05 10:40:54 2009 +0200
@@ -211,9 +211,11 @@
                 status, args = (False, '???')
         self.req.set_content_type('text/html')
         jsarg = simplejson.dumps( (status, args) )
+        domid = self.req.form.get('__domid', 'entityForm').encode(
+            self.req.encoding)
         return """<script type="text/javascript">
- window.parent.handleFormValidationResponse('entityForm', null, null, %s);
-</script>""" %  simplejson.dumps( (status, args) )
+ window.parent.handleFormValidationResponse('%s', null, null, %s);
+</script>""" %  (domid, simplejson.dumps( (status, args) ))
 
     def validation_error(self, err):
         self.req.cnx.rollback()
--- a/web/views/cwproperties.py	Thu Jun 04 20:21:40 2009 +0200
+++ b/web/views/cwproperties.py	Fri Jun 05 10:40:54 2009 +0200
@@ -212,7 +212,7 @@
         else:
             label = key
         subform = self.vreg.select_object('forms', 'base', self.req, entity=entity,
-                                     set_error_url=False)
+                                     mainform=False)
         subform.append_field(PropertyValueField(name='value', label=label,
                                                 eidparam=True))
         subform.vreg = self.vreg
--- a/web/views/editforms.py	Thu Jun 04 20:21:40 2009 +0200
+++ b/web/views/editforms.py	Fri Jun 05 10:40:54 2009 +0200
@@ -71,7 +71,7 @@
                 continue
             done.add(entity.eid)
             subform = self.vreg.select_object('forms', 'base', req, entity=entity,
-                                              set_error_url=False)
+                                              mainform=False)
             form.form_add_subform(subform)
             # don't use outofcontext view or any other that may contain inline edition form
             w(u'<li>%s</li>' % tags.a(entity.view('textoutofcontext'),
@@ -119,7 +119,6 @@
         else:
             form = self._build_relation_form(entity, value, rtype, role,
                                              row, col, vid, default)
-        form.form_add_hidden(u'__maineid', entity.eid)
         renderer = self.vreg.select_object('formrenderers', 'base', self.req,
                                       entity=entity,
                                       display_label=False, display_help=False,
@@ -194,7 +193,7 @@
 
     def init_form(self, form, entity):
         """customize your form before rendering here"""
-        form.form_add_hidden(u'__maineid', entity.eid)
+        pass
 
     def form_title(self, entity):
         """the form view title"""
@@ -307,7 +306,7 @@
         for row in xrange(len(self.rset)):
             form = self.vreg.select_object('forms', 'edition', self.req, self.rset,
                                            row=row, attrcategories=('primary',),
-                                           set_error_url=False)
+                                           mainform=False)
             # XXX rely on the EntityCompositeFormRenderer to put the eid input
             form.remove_field(form.field_by_name('eid'))
             self.form_add_subform(form)
@@ -356,8 +355,7 @@
         """fetch and render the form"""
         form = self.vreg.select_object('forms', 'edition', self.req, None,
                                        entity=entity, form_renderer_id='inline',
-                                       set_error_url=False,
-                                       copy_nav_params=False)
+                                       mainform=False, copy_nav_params=False)
         self.add_hiddens(form, entity, peid, rtype, role)
         divid = '%s-%s-%s' % (peid, rtype, entity.eid)
         title = self.schema.rschema(rtype).display_name(self.req, role)
--- a/web/views/forms.py	Thu Jun 04 20:21:40 2009 +0200
+++ b/web/views/forms.py	Fri Jun 05 10:40:54 2009 +0200
@@ -36,12 +36,12 @@
     cssstyle = None
     cwtarget = None
     redirect_path = None
-    set_error_url = True
     copy_nav_params = False
     form_buttons = None # form buttons (button widgets instances)
     form_renderer_id = 'default'
 
-    def __init__(self, req, rset=None, row=None, col=None, submitmsg=None,
+    def __init__(self, req, rset=None, row=None, col=None,
+                 submitmsg=None, mainform=True,
                  **kwargs):
         super(FieldsForm, self).__init__(req, rset, row=row, col=col)
         self.fields = list(self.__class__._fields_)
@@ -51,8 +51,9 @@
             else:
                 assert hasattr(self.__class__, key) and not key[0] == '_', key
                 setattr(self, key, val)
-        if self.set_error_url:
+        if mainform:
             self.form_add_hidden('__errorurl', self.session_key())
+            self.form_add_hidden('__domid', self.domid)
         if self.copy_nav_params:
             for param in NAV_FORM_PARAMETERS:
                 if not param in kwargs:
@@ -266,13 +267,18 @@
             self.edited_entity = self.complete_entity(self.row or 0, self.col or 0)
         self.form_add_hidden('__type', eidparam=True)
         self.form_add_hidden('eid')
+        if kwargs.get('mainform'):
+            self.form_add_hidden(u'__maineid', self.edited_entity.eid)
+            # If we need to directly attach the new object to another one
+            if self.req.list_form_param('__linkto'):
+                for linkto in self.req.list_form_param('__linkto'):
+                    self.form_add_hidden('__linkto', linkto)
+                if msg:
+                    msg = '%s %s' % (msg, self.req._('and linked'))
+                else:
+                    msg = self.req._('entity linked')
         if msg:
-            # If we need to directly attach the new object to another one
             self.form_add_hidden('__message', msg)
-        if not self.is_subform:
-            for linkto in self.req.list_form_param('__linkto'):
-                self.form_add_hidden('__linkto', linkto)
-                msg = '%s %s' % (msg, self.req._('and linked'))
 
     def _field_has_error(self, field):
         """return true if the field has some error in given validation exception
--- a/web/views/management.py	Thu Jun 04 20:21:40 2009 +0200
+++ b/web/views/management.py	Fri Jun 05 10:40:54 2009 +0200
@@ -40,6 +40,8 @@
             groups = [(_(group), group) for group in groups]
             for trad, group in sorted(groups):
                 if link:
+                    # XXX we should get a group entity and call its absolute_url
+                    # method
                     l.append(u'<a href="%s" class="%s">%s</a><br/>' % (
                     self.build_url('cwgroup/%s' % group), group, trad))
                 else:
@@ -242,7 +244,8 @@
         submiturl = self.config['submit-url']
         submitmail = self.config['submit-mail']
         if submiturl or submitmail:
-            form = self.vreg.select_object('forms', 'base', self.req, rset=None, set_error_url=False)
+            form = self.vreg.select_object('forms', 'base', self.req, rset=None,
+                                           mainform=False)
             binfo = text_error_description(ex, excinfo, req, eversion, cversions)
             form.form_add_hidden('description', binfo)
             form.form_add_hidden('__bugreporting', '1')