'))
+ schema = self._cw.vreg.schema
+ entity = self.cw_rset.get_entity(row, col)
+ rschema = schema.rschema(rtype)
lzone = self._build_landing_zone(landing_zone)
# compute value, checking perms, build form
if rschema.is_final():
@@ -185,7 +186,7 @@
return
rset = entity.related(rtype, role)
if rset:
- value = self.view(rvid, rset)
+ value = self._cw.view(rvid, rset)
else:
value = default
onsubmit = ("return inlineValidateRelationForm('%(rtype)s', '%(role)s', '%(eid)s', "
@@ -193,15 +194,15 @@
form = self._build_form(
entity, rtype, role, 'base', default, onsubmit, reload,
dict(vid=rvid, role=role, lzone=lzone))
- field = guess_field(entity.e_schema, entity.schema.rschema(rtype), role)
+ field = guess_field(entity.e_schema, schema.rschema(rtype), role)
form.append_field(field)
self.relation_form(lzone, value, form,
self._build_renderer(entity, rtype, role))
def should_edit_attribute(self, entity, rschema, role, form):
rtype = str(rschema)
- ttype = rschema.targets(entity.id, role)[0]
- afs = uicfg.autoform_section.etype_get(entity.id, rtype, role, ttype)
+ ttype = rschema.targets(entity.__regid__, role)[0]
+ afs = uicfg.autoform_section.etype_get(entity.__regid__, rtype, role, ttype)
if not (afs in self.attrcategories and entity.has_perm('update')):
self.w(entity.printable_value(rtype))
return False
@@ -213,10 +214,10 @@
return True
def should_edit_relation(self, entity, rschema, role, rvid):
- if ((role == 'subject' and not rschema.has_perm(self.req, 'add',
+ if ((role == 'subject' and not rschema.has_perm(self._cw, 'add',
fromeid=entity.eid))
or
- (role == 'object' and not rschema.has_perm(self.req, 'add',
+ (role == 'object' and not rschema.has_perm(self._cw, 'add',
toeid=entity.eid))):
self.wview(rvid, entity.related(str(rschema), role), 'null')
return False
@@ -296,7 +297,7 @@
def render_form(self, entity):
"""fetch and render the form"""
self.form_title(entity)
- form = self.vreg['forms'].select('edition', self.req, rset=entity.rset,
+ form = self._cw.vreg['forms'].select('edition', self._cw, rset=entity.rset,
row=entity.row, col=entity.col, entity=entity,
submitmsg=self.submited_message())
self.init_form(form, entity)
@@ -308,13 +309,13 @@
def form_title(self, entity):
"""the form view title"""
- ptitle = self.req._(self.title)
+ ptitle = self._cw._(self.title)
self.w(u'%s %s
' % (
entity.dc_type(), ptitle and '(%s)' % ptitle))
def submited_message(self):
"""return the message that will be displayed on successful edition"""
- return self.req._('entity edited')
+ return self._cw._('entity edited')
class CreationFormView(EditionFormView):
@@ -328,41 +329,40 @@
"""creation view for an entity"""
# at this point we know etype is a valid entity type, thanks to our
# selector
- etype = kwargs.pop('etype', self.req.form.get('etype'))
- entity = self.vreg['etypes'].etype_class(etype)(self.req)
- self.initialize_varmaker()
- entity.eid = self.varmaker.next()
+ etype = kwargs.pop('etype', self._cw.form.get('etype'))
+ entity = self._cw.vreg['etypes'].etype_class(etype)(self._cw)
+ entity.eid = self._cw.varmaker.next()
self.render_form(entity)
def form_title(self, entity):
"""the form view title"""
- if '__linkto' in self.req.form:
- if isinstance(self.req.form['__linkto'], list):
+ if '__linkto' in self._cw.form:
+ if isinstance(self._cw.form['__linkto'], list):
# XXX which one should be considered (case: add a ticket to a
# version in jpl)
- rtype, linkto_eid, role = self.req.form['__linkto'][0].split(':')
+ rtype, linkto_eid, role = self._cw.form['__linkto'][0].split(':')
else:
- rtype, linkto_eid, role = self.req.form['__linkto'].split(':')
- linkto_rset = self.req.eid_rset(linkto_eid)
+ rtype, linkto_eid, role = self._cw.form['__linkto'].split(':')
+ linkto_rset = self._cw.eid_rset(linkto_eid)
linkto_type = linkto_rset.description[0][0]
if role == 'subject':
- title = self.req.__('creating %s (%s %s %s %%(linkto)s)' % (
+ title = self._cw.__('creating %s (%s %s %s %%(linkto)s)' % (
entity.e_schema, entity.e_schema, rtype, linkto_type))
else:
- title = self.req.__('creating %s (%s %%(linkto)s %s %s)' % (
+ title = self._cw.__('creating %s (%s %%(linkto)s %s %s)' % (
entity.e_schema, linkto_type, rtype, entity.e_schema))
- msg = title % {'linkto' : self.view('incontext', linkto_rset)}
+ msg = title % {'linkto' : self._cw.view('incontext', linkto_rset)}
self.w(u'%s
' % msg)
else:
super(CreationFormView, self).form_title(entity)
def url(self):
"""return the url associated with this view"""
- return self.create_url(self.req.form.get('etype'))
+ return self.create_url(self._cw.form.get('etype'))
def submited_message(self):
"""return the message that will be displayed on successful edition"""
- return self.req._('entity created')
+ return self._cw._('entity created')
class CopyFormView(EditionFormView):
@@ -379,10 +379,9 @@
entity.complete()
self.newentity = copy(entity)
self.copying = entity
- self.initialize_varmaker()
- self.newentity.eid = self.varmaker.next()
+ self.newentity.eid = self._cw.varmaker.next()
self.w(u'\n'
- % self.req._(self.warning_message))
+ % self._cw._(self.warning_message))
super(CopyFormView, self).render_form(self.newentity)
del self.newentity
@@ -401,7 +400,7 @@
def submited_message(self):
"""return the message that will be displayed on successful edition"""
- return self.req._('entity copied')
+ return self._cw._('entity copied')
class TableEditForm(forms.CompositeForm):
@@ -414,9 +413,9 @@
def __init__(self, req, rset, **kwargs):
kwargs.setdefault('__redirectrql', rset.printable_rql())
super(TableEditForm, self).__init__(req, rset=rset, **kwargs)
- for row in xrange(len(self.rset)):
- form = self.vreg['forms'].select('edition', self.req,
- rset=self.rset, row=row,
+ for row in xrange(len(self.cw_rset)):
+ form = self._cw.vreg['forms'].select('edition', self._cw,
+ rset=self.cw_rset, row=row,
attrcategories=('primary',),
mainform=False)
# XXX rely on the EntityCompositeFormRenderer to put the eid input
@@ -434,7 +433,7 @@
should be the eid
"""
#self.form_title(entity)
- form = self.vreg['forms'].select(self.id, self.req, rset=self.rset)
+ form = self._cw.vreg['forms'].select(self.__regid__, self._cw, rset=self.cw_rset)
self.w(form.form_render())
@@ -448,9 +447,9 @@
insertions of between each row of
the resultset
"""
- rset = self.rset
+ rset = self.cw_rset
for i in xrange(len(rset)):
- self.wview(self.id, rset, row=i, **kwargs)
+ self.wview(self.__regid__, rset, row=i, **kwargs)
def cell_call(self, row, col, peid, rtype, role, i18nctx, **kwargs):
"""
@@ -458,7 +457,7 @@
:param rtype: the relation bridging `etype` and `peid`
:param role: the role played by the `peid` in the relation
"""
- entity = self.rset.get_entity(row, col)
+ entity = self.cw_rset.get_entity(row, col)
divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % (peid, rtype,
entity.eid)
self.render_form(entity, peid, rtype, role, i18nctx,
@@ -466,21 +465,21 @@
def render_form(self, entity, peid, rtype, role, i18nctx, **kwargs):
"""fetch and render the form"""
- form = self.vreg['forms'].select('edition', self.req, entity=entity,
+ form = self._cw.vreg['forms'].select('edition', self._cw, entity=entity,
form_renderer_id='inline',
mainform=False, copy_nav_params=False)
self.add_hiddens(form, entity, peid, rtype, role)
divid = '%s-%s-%s' % (peid, rtype, entity.eid)
- title = self.req.pgettext(i18nctx, 'This %s' % entity.e_schema)
+ title = self._cw.pgettext(i18nctx, 'This %s' % entity.e_schema)
removejs = self.removejs % (peid, rtype, entity.eid)
countkey = '%s_count' % rtype
try:
- self.req.data[countkey] += 1
+ self._cw.data[countkey] += 1
except:
- self.req.data[countkey] = 1
+ self._cw.data[countkey] = 1
self.w(form.form_render(divid=divid, title=title, removejs=removejs,
i18nctx=i18nctx,
- counter=self.req.data[countkey], **kwargs))
+ counter=self._cw.data[countkey], **kwargs))
def add_hiddens(self, form, entity, peid, rtype, role):
# to ease overriding (see cubes.vcsfile.views.forms for instance)
@@ -492,7 +491,7 @@
return True
# are we regenerating form because of a validation error ?
if form.form_previous_values:
- cdvalues = self.req.list_form_param(eid_param(rtype, peid),
+ cdvalues = self._cw.list_form_param(eid_param(rtype, peid),
form.form_previous_values)
if unicode(entity.eid) not in cdvalues:
return False
@@ -513,11 +512,10 @@
:param role: the role played by the `peid` in the relation
"""
try:
- cls = self.vreg['etypes'].etype_class(etype)
+ cls = self._cw.vreg['etypes'].etype_class(etype)
except:
- self.w(self.req._('no such entity type %s') % etype)
+ self.w(self._cw._('no such entity type %s') % etype)
return
- self.initialize_varmaker()
- entity = cls(self.req)
- entity.eid = self.varmaker.next()
+ entity = cls(self._cw)
+ entity.eid = self._cw.varmaker.next()
self.render_form(entity, peid, rtype, role, i18nctx, **kwargs)