merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 02 Jul 2009 10:30:44 +0200
branchstable
changeset 2233 bf3603caaf0d
parent 2231 d2052c3ccac7 (diff)
parent 2232 7837a3941327 (current diff)
child 2234 1fbcf202882d
child 2237 7e546c3d6ea5
merge
--- a/schemas/workflow.py	Thu Jul 02 10:27:42 2009 +0200
+++ b/schemas/workflow.py	Thu Jul 02 10:30:44 2009 +0200
@@ -51,7 +51,7 @@
     transition_of = SubjectRelation('CWEType', cardinality='+*',
                                     description=_('entity types which may use this transition'),
                                     constraints=[RQLConstraint('O final FALSE')])
-    destination_state = SubjectRelation('State', cardinality='?*',
+    destination_state = SubjectRelation('State', cardinality='1*',
                                         constraints=[RQLConstraint('S transition_of ET, O state_of ET')],
                                         description=_('destination state for this transition'))
 
--- a/web/views/__init__.py	Thu Jul 02 10:27:42 2009 +0200
+++ b/web/views/__init__.py	Thu Jul 02 10:30:44 2009 +0200
@@ -114,4 +114,7 @@
             self._generate(tmpfile)
             self.w(open(tmpfile).read())
         finally:
-            os.unlink(tmpfile)
+            try:
+                os.unlink(tmpfile)
+            except Exception, ex:
+                self.warning('cant delete %s: %s', tmpfile, ex)
--- a/web/views/schema.py	Thu Jul 02 10:27:42 2009 +0200
+++ b/web/views/schema.py	Thu Jul 02 10:30:44 2009 +0200
@@ -42,6 +42,7 @@
                % (entity.dc_type().capitalize(),
                   html_escape(entity.dc_long_title())))
 
+
 # CWEType ######################################################################
 
 class CWETypeOneLineView(baseviews.OneLineView):
@@ -81,11 +82,10 @@
     def cell_call(self, row, col):
         entity = self.entity(row, col)
         self.w(u'<h2>%s</h2>' % _('Attributes'))
-        rset = self.req.execute('Any N,F,D,GROUP_CONCAT(C),I,J,DE,A '
-                                'GROUPBY N,F,D,AA,A,I,J,DE '
+        rset = self.req.execute('Any N,F,D,I,J,DE,A '
                                 'ORDERBY AA WHERE A is CWAttribute, '
                                 'A ordernum AA, A defaultval D, '
-                                'A constrained_by C?, A description DE, '
+                                'A description DE, '
                                 'A fulltextindexed I, A internationalizable J, '
                                 'A relation_type R, R name N, '
                                 'A to_entity O, O name F, '
@@ -93,25 +93,22 @@
                                 {'x': entity.eid})
         self.wview('editable-table', rset, 'null', displayfilter=True)
         self.w(u'<h2>%s</h2>' % _('Relations'))
-        rset = self.req.execute('Any N,C,F,M,K,D,A ORDERBY N '
-                                'WITH N,C,F,M,D,K,A BEING ('
-                                '(Any N,C,F,M,K,D,A '
-                                'ORDERBY N WHERE A is CWRelation, '
-                                'A description D, A composite K?, '
-                                'A relation_type R, R name N, '
-                                'A to_entity O, O name F, '
-                                'A cardinality C, O meta M, '
-                                'A from_entity S, S eid %(x)s)'
-                                ' UNION '
-                                '(Any N,C,F,M,K,D,A '
-                                'ORDERBY N WHERE A is CWRelation, '
-                                'A description D, A composite K?, '
-                                'A relation_type R, R name N, '
-                                'A from_entity S, S name F, '
-                                'A cardinality C, S meta M, '
-                                'A to_entity O, O eid %(x)s))'
-                                ,{'x': entity.eid})
-        self.wview('editable-table', rset, 'null', displayfilter=True)
+        rset = self.req.execute(
+            'Any R,C,TT,K,D,A,RN,TTN ORDERBY RN '
+            'WHERE A is CWRelation, A description D, A composite K?, '
+            'A relation_type R, R name RN, A to_entity TT, TT name TTN, '
+            'A cardinality C, A from_entity S, S eid %(x)s',
+            {'x': entity.eid})
+        self.wview('editable-table', rset, 'null', displayfilter=True,
+                   displaycols=range(6), mainindex=5)
+        rset = self.req.execute(
+            'Any R,C,TT,K,D,A,RN,TTN ORDERBY RN '
+            'WHERE A is CWRelation, A description D, A composite K?, '
+            'A relation_type R, R name RN, A from_entity TT, TT name TTN, '
+            'A cardinality C, A to_entity O, O eid %(x)s',
+            {'x': entity.eid})
+        self.wview('editable-table', rset, 'null', displayfilter=True,
+                   displaycols=range(6), mainindex=5)
 
 
 class CWETypeSImageView(EntityView):
--- a/web/views/startup.py	Thu Jul 02 10:27:42 2009 +0200
+++ b/web/views/startup.py	Thu Jul 02 10:30:44 2009 +0200
@@ -195,15 +195,9 @@
     id = 'schema-text'
 
     def call(self):
-        self.w(u'<p>%s</p>' % _('This is the list of types defined in the data '
-                                'model ofin this application.'))
-        self.w(u'<p>%s</p>' % _('<em>meta</em> is True for types that are defined by the '
-                                'framework itself (e.g. User and Group). '
-                                '<em>final</em> is True for types that can not be the '
-                                'subject of a relation (e.g. Int and String).'))
-        rset = self.req.execute('Any X,M,F ORDERBY N WHERE X is CWEType, X name N, '
-                                'X meta M, X final F')
-        self.wview('editable-table', rset, displayfilter=True)
+        rset = self.req.execute('Any X ORDERBY N WHERE X is CWEType, X name N, '
+                                'X final FALSE')
+        self.wview('table', rset, displayfilter=True)
 
 
 class ManagerSchemaPermissionsView(StartupView, SecurityViewMixIn):
--- a/web/views/tableview.py	Thu Jul 02 10:27:42 2009 +0200
+++ b/web/views/tableview.py	Thu Jul 02 10:30:44 2009 +0200
@@ -93,7 +93,7 @@
 
     def call(self, title=None, subvid=None, displayfilter=None, headers=None,
              displaycols=None, displayactions=None, actions=(), divid=None,
-             cellvids=None, cellattrs=None):
+             cellvids=None, cellattrs=None, mainindex=None):
         """Dumps a table displaying a composite query
 
         :param title: title added before table
@@ -101,18 +101,18 @@
         :param displayfilter: filter that selects rows to display
         :param headers: columns' titles
         """
-        rset = self.rset
         req = self.req
         req.add_js('jquery.tablesorter.js')
         req.add_css(('cubicweb.tablesorter.css', 'cubicweb.tableview.css'))
-        # get rql description first since the filter form may remove some
-        # necessary information
-        mainindex = self.main_var_index()
+        # compute label first  since the filter form may remove some necessary
+        # information from the rql syntax tree
+        if mainindex is None:
+            mainindex = self.main_var_index()
         computed_labels = self.columns_labels(mainindex)
         hidden = True
         if not subvid and 'subvid' in req.form:
             subvid = req.form.pop('subvid')
-        divid = divid or req.form.get('divid') or 'rs%s' % make_uid(id(rset))
+        divid = divid or req.form.get('divid') or 'rs%s' % make_uid(id(self.rset))
         actions = list(actions)
         if mainindex is None:
             displayfilter, displayactions = False, False
@@ -290,7 +290,7 @@
     title = None
 
     def call(self, title=None, subvid=None, headers=None, divid=None,
-             displaycols=None, displayactions=None):
+             displaycols=None, displayactions=None, mainindex=None):
         """Dumps a table displaying a composite query"""
         actrql = self.req.form['actualrql']
         self.ensure_ro_rql(actrql)
@@ -305,7 +305,8 @@
             title = self.req.form.pop('title')
         if title:
             self.w(u'<h2>%s</h2>\n' % title)
-        mainindex = self.main_var_index()
+        if mainindex is None:
+            mainindex = self.main_var_index()
         if mainindex is not None:
             actions = self.form_filter(divid, displaycols, displayactions, True)
         else: