# HG changeset patch # User Sylvain Thénault # Date 1305905390 -7200 # Node ID 9179ae452159b8b81d648ed5dc4cfcf892cffa31 # Parent e772a2c57b0048c1062c7bd4a5328d3bb305b718# Parent 238da9684f99580f09de65b5e417b51532635fb4 backport stable diff -r e772a2c57b00 -r 9179ae452159 req.py --- a/req.py Thu May 19 18:48:26 2011 +0200 +++ b/req.py Fri May 20 17:29:50 2011 +0200 @@ -88,7 +88,7 @@ rset = ResultSet([('A',)]*size, '%s X' % etype, description=[(etype,)]*size) def get_entity(row, col=0, etype=etype, req=self, rset=rset): - return req.vreg.etype_class(etype)(req, rset, row, col) + return req.vreg['etypes'].etype_class(etype)(req, rset, row, col) rset.get_entity = get_entity rset.req = self return rset diff -r e772a2c57b00 -r 9179ae452159 server/migractions.py --- a/server/migractions.py Thu May 19 18:48:26 2011 +0200 +++ b/server/migractions.py Fri May 20 17:29:50 2011 +0200 @@ -1423,7 +1423,7 @@ return self.cmd_create_entity(etype, *args, **kwargs).eid @contextmanager - def cmd_dropped_constraints(self, etype, attrname, cstrtype, + def cmd_dropped_constraints(self, etype, attrname, cstrtype=None, droprequired=False): """context manager to drop constraints temporarily on fs_schema @@ -1443,8 +1443,9 @@ rdef = self.fs_schema.eschema(etype).rdef(attrname) original_constraints = rdef.constraints # remove constraints - rdef.constraints = [cstr for cstr in original_constraints - if not (cstrtype and isinstance(cstr, cstrtype))] + if cstrtype: + rdef.constraints = [cstr for cstr in original_constraints + if not (cstrtype and isinstance(cstr, cstrtype))] if droprequired: original_cardinality = rdef.cardinality rdef.cardinality = '?' + rdef.cardinality[1] @@ -1514,13 +1515,13 @@ rschema = self.repo.schema.rschema(attr) oldtype = rschema.objects(etype)[0] rdefeid = rschema.rproperty(etype, oldtype, 'eid') - sql = ("UPDATE CWAttribute " - "SET to_entity=(SELECT eid FROM CWEType WHERE name='%s')" - "WHERE eid=%s") % (newtype, rdefeid) + sql = ("UPDATE cw_CWAttribute " + "SET cw_to_entity=(SELECT cw_eid FROM cw_CWEType WHERE cw_name='%s')" + "WHERE cw_eid=%s") % (newtype, rdefeid) self.sqlexec(sql, ask_confirm=False) dbhelper = self.repo.system_source.dbhelper sqltype = dbhelper.TYPE_MAPPING[newtype] - sql = 'ALTER TABLE %s ALTER COLUMN %s TYPE %s' % (etype, attr, sqltype) + sql = 'ALTER TABLE cw_%s ALTER COLUMN cw_%s TYPE %s' % (etype, attr, sqltype) self.sqlexec(sql, ask_confirm=False) if commit: self.commit() diff -r e772a2c57b00 -r 9179ae452159 uilib.py --- a/uilib.py Thu May 19 18:48:26 2011 +0200 +++ b/uilib.py Fri May 20 17:29:50 2011 +0200 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. diff -r e772a2c57b00 -r 9179ae452159 web/formwidgets.py --- a/web/formwidgets.py Thu May 19 18:48:26 2011 +0200 +++ b/web/formwidgets.py Fri May 20 17:29:50 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. diff -r e772a2c57b00 -r 9179ae452159 web/request.py --- a/web/request.py Thu May 19 18:48:26 2011 +0200 +++ b/web/request.py Fri May 20 17:29:50 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. diff -r e772a2c57b00 -r 9179ae452159 web/schemaviewer.py --- a/web/schemaviewer.py Thu May 19 18:48:26 2011 +0200 +++ b/web/schemaviewer.py Fri May 20 17:29:50 2011 +0200 @@ -151,9 +151,9 @@ continue label = rschema.type if role == 'subject': - cards = rschema.rproperty(eschema, oeschema, 'cardinality') + cards = rschema.rdef(eschema, oeschema).cardinality else: - cards = rschema.rproperty(oeschema, eschema, 'cardinality') + cards = rschema.rdef(oeschema, eschema).cardinality cards = cards[::-1] label = '%s %s %s' % (CARD_MAP[cards[1]], label, CARD_MAP[cards[0]]) diff -r e772a2c57b00 -r 9179ae452159 web/views/autoform.py --- a/web/views/autoform.py Thu May 19 18:48:26 2011 +0200 +++ b/web/views/autoform.py Fri May 20 17:29:50 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. diff -r e772a2c57b00 -r 9179ae452159 web/views/formrenderers.py --- a/web/views/formrenderers.py Thu May 19 18:48:26 2011 +0200 +++ b/web/views/formrenderers.py Fri May 20 17:29:50 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -40,7 +40,7 @@ from logilab.common import dictattr from logilab.mtconverter import xml_escape -from cubicweb import tags +from cubicweb import tags, uilib from cubicweb.appobject import AppObject from cubicweb.selectors import is_instance, yes from cubicweb.utils import json_dumps, support_args @@ -112,18 +112,21 @@ data = [] _w = data.append _w(self.open_form(form, values)) - if self.display_progress_div: - _w(u'
%s
' % self._cw._('validating...')) - _w(u'\n
\n') - self.render_fields(_w, form, values) - self.render_buttons(_w, form) - _w(u'\n
\n') + self.render_content(_w, form, values) _w(self.close_form(form, values)) errormsg = self.error_message(form) if errormsg: data.insert(0, errormsg) w(''.join(data)) + def render_content(self, w, form, values): + if self.display_progress_div: + w(u'
%s
' % self._cw._('validating...')) + w(u'\n
\n') + self.render_fields(w, form, values) + self.render_buttons(w, form) + w(u'\n
\n') + def render_label(self, form, field): if field.label is None: return u'' @@ -179,24 +182,25 @@ return u'
%s
' % errormsg return u'' - def open_form(self, form, values): + def open_form(self, form, values, **attrs): if form.needs_multipart: enctype = u'multipart/form-data' else: enctype = u'application/x-www-form-urlencoded' - tag = (u'
' + attrs.setdefault('cubicweb:target', form.cwtarget) + return '' % uilib.sgml_attributes(attrs) def close_form(self, form, values): """seems dumb but important for consistency w/ close form, and necessary diff -r e772a2c57b00 -r 9179ae452159 web/views/workflow.py --- a/web/views/workflow.py Thu May 19 18:48:26 2011 +0200 +++ b/web/views/workflow.py Fri May 20 17:29:50 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -114,7 +114,7 @@ def get_form(self, entity, transition, **kwargs): # XXX used to specify both rset/row/col and entity in case implements - # selector (and not implements) is used on custom form + # selector (and not is_instance) is used on custom form form = self._cw.vreg['forms'].select( 'changestate', self._cw, entity=entity, transition=transition, redirect_path=self.redirectpath(entity), **kwargs)