--- a/web/controller.py Tue Oct 13 12:04:36 2009 +0200
+++ b/web/controller.py Tue Oct 13 15:59:05 2009 +0200
@@ -89,12 +89,12 @@
# XXX assigning to self really necessary?
self.cw_rset = None
if rql:
- self.req.ensure_ro_rql(rql)
+ self._cw.ensure_ro_rql(rql)
if not isinstance(rql, unicode):
- rql = unicode(rql, self.req.encoding)
- pp = self.vreg['components'].select_or_none('magicsearch', self.req)
+ rql = unicode(rql, self._cw.encoding)
+ pp = self._cw.vreg['components'].select_or_none('magicsearch', self._cw)
if pp is not None:
- self.cw_rset = pp.process_query(rql, self.req)
+ self.cw_rset = pp.process_query(rql)
return self.cw_rset
def check_expected_params(self, params):
@@ -103,7 +103,7 @@
"""
missing = []
for param in params:
- if not self.req.form.get(param):
+ if not self._cw.form.get(param):
missing.append(param)
if missing:
raise RequestError('missing required parameter(s): %s'
@@ -123,7 +123,7 @@
redirect_info = set()
eidtypes = tuple(eidtypes)
for eid, etype in eidtypes:
- entity = self.req.entity_from_eid(eid, etype)
+ entity = self._cw.entity_from_eid(eid, etype)
path, params = entity.after_deletion_path()
redirect_info.add( (path, tuple(params.iteritems())) )
entity.delete()
@@ -133,22 +133,22 @@
else:
self._after_deletion_path = iter(redirect_info).next()
if len(eidtypes) > 1:
- self.req.set_message(self.req._('entities deleted'))
+ self._cw.set_message(self._cw._('entities deleted'))
else:
- self.req.set_message(self.req._('entity deleted'))
+ self._cw.set_message(self._cw._('entity deleted'))
def delete_relations(self, rdefs):
"""delete relations from the repository"""
# FIXME convert to using the syntax subject:relation:eids
- execute = self.req.execute
+ execute = self._cw.execute
for subj, rtype, obj in rdefs:
rql = 'DELETE X %s Y where X eid %%(x)s, Y eid %%(y)s' % rtype
execute(rql, {'x': subj, 'y': obj}, ('x', 'y'))
- self.req.set_message(self.req._('relations deleted'))
+ self._cw.set_message(self._cw._('relations deleted'))
def insert_relations(self, rdefs):
"""insert relations into the repository"""
- execute = self.req.execute
+ execute = self._cw.execute
for subj, rtype, obj in rdefs:
rql = 'SET X %s Y where X eid %%(x)s, Y eid %%(y)s' % rtype
execute(rql, {'x': subj, 'y': obj}, ('x', 'y'))
@@ -160,11 +160,11 @@
"""
newparams = {}
# sets message if needed
- if self.req.message:
- newparams['__message'] = self.req.message
- if self.req.form.has_key('__action_apply'):
+ if self._cw.message:
+ newparams['__message'] = self._cw.message
+ if self._cw.form.has_key('__action_apply'):
self._return_to_edition_view(newparams)
- if self.req.form.has_key('__action_cancel'):
+ if self._cw.form.has_key('__action_cancel'):
self._return_to_lastpage(newparams)
else:
self._return_to_original_view(newparams)
@@ -173,7 +173,7 @@
def _return_to_original_view(self, newparams):
"""validate-button case"""
# transforms __redirect[*] parameters into regular form parameters
- newparams.update(redirect_params(self.req.form))
+ newparams.update(redirect_params(self._cw.form))
# find out if we have some explicit `rql` needs
rql = newparams.pop('rql', None)
# if rql is needed (explicit __redirectrql or multiple deletions for
@@ -181,9 +181,9 @@
if rql:
path = 'view'
newparams['rql'] = rql
- elif '__redirectpath' in self.req.form:
+ elif '__redirectpath' in self._cw.form:
# if redirect path was explicitly specified in the form, use it
- path = self.req.form['__redirectpath']
+ path = self._cw.form['__redirectpath']
if self._edited_entity and path != self._edited_entity.rest_path():
# XXX may be here on modification? if yes the message should be
# modified where __createdpath is detected (cw.web.request)
@@ -199,18 +199,18 @@
else:
path = 'view'
url = self._cw.build_url(path, **newparams)
- url = append_url_params(url, self.req.form.get('__redirectparams'))
+ url = append_url_params(url, self._cw.form.get('__redirectparams'))
raise Redirect(url)
def _return_to_edition_view(self, newparams):
"""apply-button case"""
- form = self.req.form
+ form = self._cw.form
if self._edited_entity:
path = self._edited_entity.rest_path()
newparams.pop('rql', None)
# else, fallback on the old `view?rql=...` url form
- elif 'rql' in self.req.form:
+ elif 'rql' in self._cw.form:
path = 'view'
newparams['rql'] = form['rql']
else:
@@ -232,13 +232,13 @@
__redirectpath is specifying that place if found, else we look in the
request breadcrumbs for the last visited page.
"""
- if '__redirectpath' in self.req.form:
+ if '__redirectpath' in self._cw.form:
# if redirect path was explicitly specified in the form, use it
- path = self.req.form['__redirectpath']
+ path = self._cw.form['__redirectpath']
url = self._cw.build_url(path, **newparams)
- url = append_url_params(url, self.req.form.get('__redirectparams'))
+ url = append_url_params(url, self._cw.form.get('__redirectparams'))
else:
- url = self.req.last_visited_page()
+ url = self._cw.last_visited_page()
raise Redirect(url)
--- a/web/views/autoform.py Tue Oct 13 12:04:36 2009 +0200
+++ b/web/views/autoform.py Tue Oct 13 15:59:05 2009 +0200
@@ -360,35 +360,46 @@
## default form ui configuration ##############################################
+_afs = uicfg.autoform_section
# use primary and not generated for eid since it has to be an hidden
-uicfg.autoform_section.tag_attribute(('*', 'eid'), 'primary')
-uicfg.autoform_section.tag_attribute(('*', 'description'), 'secondary')
-uicfg.autoform_section.tag_attribute(('*', 'creation_date'), 'metadata')
-uicfg.autoform_section.tag_attribute(('*', 'modification_date'), 'metadata')
-uicfg.autoform_section.tag_attribute(('*', 'cwuri'), 'metadata')
-uicfg.autoform_section.tag_attribute(('*', 'has_text'), 'generated')
-uicfg.autoform_section.tag_subject_of(('*', 'in_state', '*'), 'generated')
-uicfg.autoform_section.tag_subject_of(('*', 'owned_by', '*'), 'metadata')
-uicfg.autoform_section.tag_subject_of(('*', 'created_by', '*'), 'metadata')
-uicfg.autoform_section.tag_subject_of(('*', 'require_permission', '*'), 'generated')
-uicfg.autoform_section.tag_subject_of(('*', 'by_transition', '*'), 'primary')
-uicfg.autoform_section.tag_object_of(('*', 'by_transition', '*'), 'generated')
-uicfg.autoform_section.tag_object_of(('*', 'from_state', '*'), 'generated')
-uicfg.autoform_section.tag_object_of(('*', 'to_state', '*'), 'generated')
-uicfg.autoform_section.tag_subject_of(('*', 'wf_info_for', '*'), 'primary')
-uicfg.autoform_section.tag_object_of(('*', 'wf_info_for', '*'), 'generated')
-uicfg.autoform_section.tag_subject_of(('*', 'for_user', '*'), 'generated')
-uicfg.autoform_section.tag_object_of(('*', 'for_user', '*'), 'generated')
-uicfg.autoform_section.tag_subject_of(('CWPermission', 'require_group', '*'), 'primary')
-uicfg.autoform_section.tag_attribute(('CWEType', 'final'), 'generated')
-uicfg.autoform_section.tag_attribute(('CWRType', 'final'), 'generated')
-uicfg.autoform_section.tag_attribute(('CWUser', 'firstname'), 'secondary')
-uicfg.autoform_section.tag_attribute(('CWUser', 'surname'), 'secondary')
-uicfg.autoform_section.tag_attribute(('CWUser', 'last_login_time'), 'metadata')
-uicfg.autoform_section.tag_subject_of(('CWUser', 'in_group', '*'), 'primary')
-uicfg.autoform_section.tag_object_of(('*', 'bookmarked_by', 'CWUser'), 'metadata')
-uicfg.autoform_section.tag_attribute(('Bookmark', 'path'), 'primary')
-uicfg.autoform_section.tag_subject_of(('*', 'primary_email', '*'), 'generic')
+_afs.tag_attribute(('*', 'eid'), 'main', 'attributes')
+_afs.tag_attribute(('*', 'eid'), 'muledit', 'attributes')
+_afs.tag_attribute(('*', 'description'), 'main', 'attributes')
+_afs.tag_attribute(('*', 'creation_date'), 'main', 'metadata')
+_afs.tag_attribute(('*', 'modification_date'), 'main', 'metadata')
+_afs.tag_attribute(('*', 'cwuri'), 'main', 'metadata')
+_afs.tag_attribute(('*', 'has_text'), 'main', 'hidden')
+_afs.tag_subject_of(('*', 'in_state', '*'), 'main', 'hidden')
+_afs.tag_subject_of(('*', 'owned_by', '*'), 'main', 'metadata')
+_afs.tag_subject_of(('*', 'created_by', '*'), 'main', 'metadata')
+_afs.tag_subject_of(('*', 'require_permission', '*'), 'main', 'hidden')
+_afs.tag_subject_of(('*', 'by_transition', '*'), 'main', 'attributes')
+_afs.tag_subject_of(('*', 'by_transition', '*'), 'muledit', 'attributes')
+_afs.tag_object_of(('*', 'by_transition', '*'), 'main', 'hidden')
+_afs.tag_object_of(('*', 'from_state', '*'), 'main', 'hidden')
+_afs.tag_object_of(('*', 'to_state', '*'), 'main', 'hidden')
+_afs.tag_subject_of(('*', 'wf_info_for', '*'), 'main', 'attributes')
+_afs.tag_subject_of(('*', 'wf_info_for', '*'), 'muledit', 'attributes')
+_afs.tag_object_of(('*', 'wf_info_for', '*'), 'main', 'hidden')
+_afs.tag_subject_of(('*', 'for_user', '*'), 'main', 'hidden')
+_afs.tag_object_of(('*', 'for_user', '*'), 'main', 'hidden')
+_afs.tag_subject_of(('CWPermission', 'require_group', '*'), 'main', 'attributes')
+_afs.tag_subject_of(('CWPermission', 'require_group', '*'), 'muledit', 'attributes')
+_afs.tag_attribute(('CWEType', 'final'), 'main', 'hidden')
+_afs.tag_attribute(('CWRType', 'final'), 'main', 'hidden')
+_afs.tag_attribute(('CWUser', 'firstname'), 'main', 'attributes')
+_afs.tag_attribute(('CWUser', 'surname'), 'main', 'attributes')
+_afs.tag_attribute(('CWUser', 'last_login_time'), 'main', 'metadata')
+_afs.tag_subject_of(('CWUser', 'in_group', '*'), 'main', 'attributes')
+_afs.tag_subject_of(('CWUser', 'in_group', '*'), 'muledit', 'attributes')
+_afs.tag_object_of(('*', 'bookmarked_by', 'CWUser'), 'main', 'metadata')
+_afs.tag_attribute(('Bookmark', 'path'), 'main', 'attributes')
+_afs.tag_attribute(('Bookmark', 'path'), 'muledit', 'attributes')
+_afs.tag_subject_of(('*', 'primary_email', '*'), 'main', 'relations')
+_afs.tag_subject_of(('*', 'use_email', '*'), 'main', 'inlined')
+_afs.tag_subject_of(('CWRelation', 'relation_type', '*'), 'main', 'inlined')
+_afs.tag_subject_of(('CWRelation', 'from_entity', '*'), 'main', 'inlined')
+_afs.tag_subject_of(('CWRelation', 'to_entity', '*'), 'main', 'inlined')
uicfg.autoform_field_kwargs.tag_attribute(('RQLExpression', 'expression'),
{'widget': fwdgs.TextInput})
@@ -396,8 +407,3 @@
{'widget': fwdgs.TextInput})
uicfg.autoform_field_kwargs.tag_subject_of(('TrInfo', 'wf_info_for', '*'),
{'widget': fwdgs.HiddenInput})
-
-uicfg.autoform_is_inlined.tag_subject_of(('*', 'use_email', '*'), True)
-uicfg.autoform_is_inlined.tag_subject_of(('CWRelation', 'relation_type', '*'), True)
-uicfg.autoform_is_inlined.tag_subject_of(('CWRelation', 'from_entity', '*'), True)
-uicfg.autoform_is_inlined.tag_subject_of(('CWRelation', 'to_entity', '*'), True)