# HG changeset patch # User Julien Jehannet # Date 1232734889 -3600 # Node ID 1158231e7360f1ef6ce3eb20f744cd60bc29c863 # Parent 75d242975792404ee5ba2016cf22aae34695208e# Parent e7ae975534e4d47cb2aba9fd7cc0403d875a4785 (merge) diff -r 75d242975792 -r 1158231e7360 common/appobject.py --- a/common/appobject.py Fri Jan 23 19:18:28 2009 +0100 +++ b/common/appobject.py Fri Jan 23 19:21:29 2009 +0100 @@ -1,7 +1,7 @@ """Base class for dynamically loaded objects manipulated in the web interface :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -12,6 +12,8 @@ from simplejson import dumps from logilab.common.deprecation import obsolete + +from rql.nodes import VariableRef, SubQuery from rql.stmts import Union, Select from cubicweb import Unauthorized diff -r 75d242975792 -r 1158231e7360 common/entity.py --- a/common/entity.py Fri Jan 23 19:18:28 2009 +0100 +++ b/common/entity.py Fri Jan 23 19:21:29 2009 +0100 @@ -998,6 +998,7 @@ _done.add(self.eid) containers = tuple(self.e_schema.fulltext_containers()) if containers: + yielded = False for rschema, target in containers: if target == 'object': targets = getattr(self, rschema.type) @@ -1008,6 +1009,9 @@ continue for container in entity.fti_containers(_done): yield container + yielded = True + if not yielded: + yield self else: yield self diff -r 75d242975792 -r 1158231e7360 common/migration.py --- a/common/migration.py Fri Jan 23 19:18:28 2009 +0100 +++ b/common/migration.py Fri Jan 23 19:21:29 2009 +0100 @@ -346,7 +346,7 @@ if optdescr[0] == 'added': optdict = self.config.get_option_def(optdescr[1]) if optdict.get('default') is REQUIRED: - self.config.input_option(option, optdict) + self.config.input_option(optdescr[1], optdict) self.config.generate_config(open(newconfig, 'w')) show_diffs(configfile, newconfig) if exists(newconfig): diff -r 75d242975792 -r 1158231e7360 common/mixins.py --- a/common/mixins.py Fri Jan 23 19:18:28 2009 +0100 +++ b/common/mixins.py Fri Jan 23 19:21:29 2009 +0100 @@ -165,7 +165,11 @@ @property def state(self): - return self.in_state[0].name + try: + return self.in_state[0].name + except IndexError: + self.warning('entity %s has no state', self) + return None @property def displayable_state(self): diff -r 75d242975792 -r 1158231e7360 common/selectors.py --- a/common/selectors.py Fri Jan 23 19:18:28 2009 +0100 +++ b/common/selectors.py Fri Jan 23 19:21:29 2009 +0100 @@ -499,7 +499,7 @@ propval = req.property_value('%s.%s.context' % (cls.__registry__, cls.id)) if not propval: propval = cls.context - if context is not None and propval is not None and context != propval: + if context is not None and propval and context != propval: return 0 return 1 contextprop_selector = deprecated_function(match_context_prop) diff -r 75d242975792 -r 1158231e7360 goa/__init__.py --- a/goa/__init__.py Fri Jan 23 19:18:28 2009 +0100 +++ b/goa/__init__.py Fri Jan 23 19:21:29 2009 +0100 @@ -28,7 +28,7 @@ regular python datetime object """ if yamstype is None: - yamstype = guess_yamstype_from_date(datetimeobj) + yamstype = guess_yamstype_for_date(datetimeobj) assert yamstype is not None if yamstype == 'Datetime': # don't use date, db model doesn't actually support it, only datetime diff -r 75d242975792 -r 1158231e7360 goa/db.py --- a/goa/db.py Fri Jan 23 19:18:28 2009 +0100 +++ b/goa/db.py Fri Jan 23 19:21:29 2009 +0100 @@ -391,7 +391,7 @@ @classmethod def kind(cls): - return self.id + return cls.id @classmethod def properties(cls): diff -r 75d242975792 -r 1158231e7360 goa/overrides/rqlannotation.py --- a/goa/overrides/rqlannotation.py Fri Jan 23 19:18:28 2009 +0100 +++ b/goa/overrides/rqlannotation.py Fri Jan 23 19:21:29 2009 +0100 @@ -1,4 +1,4 @@ -def set_qdata(union, noinvariant): +def set_qdata(getrschema, union, noinvariant): pass class SQLGenAnnotator(object): diff -r 75d242975792 -r 1158231e7360 goa/testlib.py --- a/goa/testlib.py Fri Jan 23 19:18:28 2009 +0100 +++ b/goa/testlib.py Fri Jan 23 19:21:29 2009 +0100 @@ -7,7 +7,7 @@ # additional monkey patches necessary in regular cubicweb environment from cubicweb.server import rqlannotation from cubicweb.goa.overrides import rqlannotation as goarqlannotation -rqlannotation.sqlgen_annotate = goarqlannotation.sqlgen_annotate +rqlannotation.SQLGenAnnotator = goarqlannotation.SQLGenAnnotator rqlannotation.set_qdata = goarqlannotation.set_qdata try: diff -r 75d242975792 -r 1158231e7360 goa/tools/i18n.py --- a/goa/tools/i18n.py Fri Jan 23 19:18:28 2009 +0100 +++ b/goa/tools/i18n.py Fri Jan 23 19:21:29 2009 +0100 @@ -221,7 +221,7 @@ os.chdir(appdirectory) potfiles = [] if osp.exists(osp.join('i18n', 'entities.pot')): - potfiles = potfiles.append( osp.join('i18n', scfile) ) + potfiles = potfiles.append( osp.join('i18n', 'entities.pot') ) print '******** extract schema messages' schemapot = osp.join(tempdir, 'schema.pot') potfiles.append(schemapot) diff -r 75d242975792 -r 1158231e7360 server/migractions.py --- a/server/migractions.py Fri Jan 23 19:18:28 2009 +0100 +++ b/server/migractions.py Fri Jan 23 19:21:29 2009 +0100 @@ -11,7 +11,7 @@ :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -679,11 +679,11 @@ espschema = eschema.specializes() if repospschema and not espschema: self.rqlexec('DELETE X specializes Y WHERE X is EEType, X name %(x)s', - {'x': str(repoechema)}) + {'x': str(repoeschema)}) elif not repospschema and espschema: self.rqlexec('SET X specializes Y WHERE X is EEType, X name %(x)s, ' 'Y is EEType, Y name %(y)s', - {'x': str(repoechema), 'y': str(epschema)}) + {'x': str(repoeschema), 'y': str(espschema)}) self.rqlexecall(ss.updateeschema2rql(eschema), ask_confirm=self.verbosity >= 2) for rschema, targettypes, x in eschema.relation_definitions(True): diff -r 75d242975792 -r 1158231e7360 server/msplanner.py --- a/server/msplanner.py Fri Jan 23 19:18:28 2009 +0100 +++ b/server/msplanner.py Fri Jan 23 19:21:29 2009 +0100 @@ -999,7 +999,9 @@ step = AggrStep(plan, selection, select, atemptable, temptable) step.children = steps elif len(steps) > 1: - if select.need_intersect: + if select.need_intersect or any(select.need_intersect + for step in steps + for select in step.union.children): if temptable: step = IntersectFetchStep(plan) else: diff -r 75d242975792 -r 1158231e7360 server/mssteps.py --- a/server/mssteps.py Fri Jan 23 19:18:28 2009 +0100 +++ b/server/mssteps.py Fri Jan 23 19:21:29 2009 +0100 @@ -6,7 +6,7 @@ for now) :organization: Logilab -:copyright: 2003-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -274,7 +274,7 @@ result &= frozenset(step.execute()) result = list(result) if self.offset: - result = result[offset:] + result = result[self.offset:] if self.limit: result = result[:limit] return result diff -r 75d242975792 -r 1158231e7360 server/repository.py --- a/server/repository.py Fri Jan 23 19:18:28 2009 +0100 +++ b/server/repository.py Fri Jan 23 19:21:29 2009 +0100 @@ -791,7 +791,7 @@ # since the current session user may not have required permissions to # do necessary stuff and we don't want to commit user session. # - # More other, even if session is already an internal session but is + # Moreover, even if session is already an internal session but is # processing a commit, we have to use another one if not session.is_internal_session: session = self.internal_session() @@ -803,6 +803,7 @@ entity = source.before_entity_insertion(session, lid, etype, eid) if source.should_call_hooks: self.hm.call_hooks('before_add_entity', etype, session, entity) + # XXX call add_info with complete=False ? self.add_info(session, entity, source, lid) source.after_entity_insertion(session, lid, entity) if source.should_call_hooks: diff -r 75d242975792 -r 1158231e7360 skeleton/__pkginfo__.py.tmpl --- a/skeleton/__pkginfo__.py.tmpl Fri Jan 23 19:18:28 2009 +0100 +++ b/skeleton/__pkginfo__.py.tmpl Fri Jan 23 19:21:29 2009 +0100 @@ -10,8 +10,8 @@ copyright = '''Copyright (c) %(year)s %(author)s. %(author-web-site)s -- mailto:%(author-email)s''' -author = %(author)s' -author_email = %(author-email)s' +author = '%(author)s' +author_email = '%(author-email)s' short_desc = '%(shortdesc)s' long_desc = '''%(longdesc)s''' diff -r 75d242975792 -r 1158231e7360 web/box.py --- a/web/box.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/box.py Fri Jan 23 19:21:29 2009 +0100 @@ -14,9 +14,9 @@ accepts_registerer, extresources_registerer, etype_rtype_priority_registerer) from cubicweb.common.selectors import ( - etype_rtype_selector, one_line_rset, accept, accept_rtype_selector, + etype_rtype_selector, one_line_rset, accept, has_relation, primary_view, match_context_prop, has_related_entities, - _rqlcondition_selector) + _rql_condition) from cubicweb.common.view import Template from cubicweb.common.appobject import ReloadableMixIn @@ -152,8 +152,7 @@ __registerer__ = accepts_registerer __selectors__ = (one_line_rset, primary_view, match_context_prop, etype_rtype_selector, - accept_rtype_selector, accept, - _rqlcondition_selector) + has_relation, accept, _rql_condition) accepts = ('Any',) context = 'incontext' condition = None @@ -185,7 +184,7 @@ class attributes. """ - def cell_call(self, row, col): + def cell_call(self, row, col, view=None): self.req.add_js('cubicweb.ajax.js') entity = self.entity(row, col) box = SideBoxWidget(display_name(self.req, self.rtype), self.id) diff -r 75d242975792 -r 1158231e7360 web/facet.py --- a/web/facet.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/facet.py Fri Jan 23 19:21:29 2009 +0100 @@ -245,11 +245,11 @@ help=_('display order of the box')), _('context'): dict(type='String', default=None, # None <-> both - vocabulary=(_('tablefilter'), _('facetbox'), None), + vocabulary=(_('tablefilter'), _('facetbox'), ''), help=_('context where this box should be displayed')), } visible = True - context = None + context = '' needs_update = False start_unfolded = True diff -r 75d242975792 -r 1158231e7360 web/test/jstest_python.jst --- a/web/test/jstest_python.jst Fri Jan 23 19:18:28 2009 +0100 +++ b/web/test/jstest_python.jst Fri Jan 23 19:21:29 2009 +0100 @@ -1,11 +1,13 @@ +// run tests with the following command line : +// $ crosscheck jstest_python.jst crosscheck.addTest({ setup: function() { crosscheck.load("testutils.js"); crosscheck.load("../data/jquery.js"); - crosscheck.load("../data/compat.js"); - crosscheck.load("../data/python.js"); + crosscheck.load("../data/cubicweb.compat.js"); + crosscheck.load("../data/cubicweb.python.js"); }, test_basic_number_parsing: function () { diff -r 75d242975792 -r 1158231e7360 web/test/unittest_owl.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/test/unittest_owl.py Fri Jan 23 19:21:29 2009 +0100 @@ -0,0 +1,4075 @@ +"""unittests for schema2dot""" + +import os + +from logilab.common.testlib import TestCase, unittest_main +from logilab.common.compat import set +from cubicweb.devtools.testlib import WebTest + +from lxml import etree +from StringIO import StringIO + + +class OWLTC(WebTest): + + def test_schema2owl(self): + + parser = etree.XMLParser(dtd_validation=True) + + owl= StringIO(''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +''') + + rdf = StringIO(''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ''') + + + xmlschema_rdf = etree.parse(rdf) + xmlschema_owl = etree.parse(owl) + + owlschema = etree.XMLSchema(xmlschema_owl) + valid = StringIO(''' + + + + + + + ]> + + + + + inst_jplorg2 Cubicweb OWL Ontology + + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + + n + + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + 1 + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + 1 + 1 + + + + + + 1 + 1 + + + + + + n + + + + + + n + + + + + + 1 + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + n + + + + + + 1 + 1 + + + + + + n + + + + + + 1 + 1 + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + n + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ''') + doc = etree.parse(valid) + owlschema.validate(doc) + +if __name__ == '__main__': + unittest_main() + diff -r 75d242975792 -r 1158231e7360 web/test/unittest_viewselector.py --- a/web/test/unittest_viewselector.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/test/unittest_viewselector.py Fri Jan 23 19:21:29 2009 +0100 @@ -15,9 +15,9 @@ from cubicweb.web._exceptions import NoSelectableObject from cubicweb.web.action import Action from cubicweb.web.views import (baseviews, tableview, baseforms, calendar, - management, embedding, actions, startup, - euser, schemaentities, xbel, vcard, - idownloadable, wdoc, debug) + management, embedding, actions, startup, + euser, schemaentities, xbel, vcard, + treeview, idownloadable, wdoc, debug) from cubicweb.entities.lib import Card from cubicweb.interfaces import IMileStone @@ -94,14 +94,17 @@ [('csvexport', baseviews.CSVRsetView), ('ecsvexport', baseviews.CSVEntityView), ('editable-table', tableview.EditableTableView), + ('filetree', treeview.FileTreeView), ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('primary', baseviews.PrimaryView), + ('rsetxml', baseviews.XMLRsetView), ('rss', baseviews.RssView), ('secondary', baseviews.SecondaryView), ('security', management.SecurityManagementView), ('table', tableview.TableView), ('text', baseviews.TextView), + ('treeview', treeview.TreeView), ('xbel', xbel.XbelView), ('xml', baseviews.XmlView), ]) @@ -111,14 +114,17 @@ [('csvexport', baseviews.CSVRsetView), ('ecsvexport', baseviews.CSVEntityView), ('editable-table', tableview.EditableTableView), + ('filetree', treeview.FileTreeView), ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('primary', baseviews.PrimaryView), + ('rsetxml', baseviews.XMLRsetView), ('rss', baseviews.RssView), ('secondary', baseviews.SecondaryView), ('security', management.SecurityManagementView), ('table', tableview.TableView), ('text', baseviews.TextView), + ('treeview', treeview.TreeView), ('xbel', xbel.XbelView), ('xml', baseviews.XmlView), ]) @@ -128,14 +134,17 @@ [('csvexport', baseviews.CSVRsetView), ('ecsvexport', baseviews.CSVEntityView), ('editable-table', tableview.EditableTableView), + ('filetree', treeview.FileTreeView), ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('primary', baseviews.PrimaryView), + ('rsetxml', baseviews.XMLRsetView), ('rss', baseviews.RssView), ('secondary', baseviews.SecondaryView), ('security', management.SecurityManagementView), ('table', tableview.TableView), ('text', baseviews.TextView), + ('treeview', treeview.TreeView), ('xbel', xbel.XbelView), ('xml', baseviews.XmlView), ]) @@ -144,6 +153,7 @@ self.assertListEqual(self.pviews(req, rset), [('csvexport', baseviews.CSVRsetView), ('editable-table', tableview.EditableTableView), + ('rsetxml', baseviews.XMLRsetView), ('table', tableview.TableView), ]) # list of euser entities @@ -152,14 +162,17 @@ [('csvexport', baseviews.CSVRsetView), ('ecsvexport', baseviews.CSVEntityView), ('editable-table', tableview.EditableTableView), + ('filetree', treeview.FileTreeView), ('list', baseviews.ListView), ('oneline', baseviews.OneLineView), ('primary', euser.EUserPrimaryView), + ('rsetxml', baseviews.XMLRsetView), ('rss', baseviews.RssView), ('secondary', baseviews.SecondaryView), ('security', management.SecurityManagementView), ('table', tableview.TableView), ('text', baseviews.TextView), + ('treeview', treeview.TreeView), ('vcard', vcard.VCardEUserView), ('xbel', xbel.XbelView), ('xml', baseviews.XmlView), diff -r 75d242975792 -r 1158231e7360 web/views/basecontrollers.py --- a/web/views/basecontrollers.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/views/basecontrollers.py Fri Jan 23 19:21:29 2009 +0100 @@ -235,7 +235,7 @@ stream.write(u'
') vtitle = self.req.form.get('vtitle') if vtitle: - w(u'

%s

\n' % vtitle) + stream.write(u'

%s

\n' % vtitle) view.pagination(req, rset, view.w, not view.need_navigation) if divid == 'pageContent': stream.write(u'
') diff -r 75d242975792 -r 1158231e7360 web/views/navigation.py --- a/web/views/navigation.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/views/navigation.py Fri Jan 23 19:21:29 2009 +0100 @@ -11,9 +11,9 @@ from logilab.mtconverter import html_escape from cubicweb.interfaces import IPrevNext -from cubicweb.common.selectors import (paginated_rset, sortedrset_selector, - primary_view, match_context_prop, - one_line_rset, implement_interface) +from cubicweb.common.selectors import (paginated_rset, sorted_rset, + primary_view, match_context_prop, + one_line_rset, implement_interface) from cubicweb.common.uilib import cut from cubicweb.web.component import EntityVComponent, NavigationComponent @@ -49,7 +49,7 @@ """sorted navigation apply if navigation is needed (according to page size) and if the result set is sorted """ - __selectors__ = (paginated_rset, sortedrset_selector) + __selectors__ = (paginated_rset, sorted_rset) # number of considered chars to build page links nb_chars = 5 diff -r 75d242975792 -r 1158231e7360 web/views/startup.py --- a/web/views/startup.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/views/startup.py Fri Jan 23 19:21:29 2009 +0100 @@ -15,6 +15,24 @@ _ = unicode +OWL_CARD_MAP = {'1': '', + '?': '1', + '+': '1', + '*': '' + } + +OWL_CARD_MAP_DATA = {'String': 'xsd:string', + 'Datetime': 'xsd:dateTime', + 'Bytes': 'xsd:byte', + 'Float': 'xsd:float', + 'Boolean': 'xsd:boolean', + 'Int': 'xsd:int', + 'Date':'xsd:date', + 'Time': 'xsd:time', + 'Password': 'xsd:byte', + 'Decimal' : 'xsd:decimal', + 'Interval': 'xsd:duration' + } class ManageView(StartupView): id = 'manage' @@ -190,3 +208,162 @@ skipmeta=skipmeta) self.w(ureport_as_html(layout)) + +class OWLView(StartupView): + id = 'owl' + title = _('owl') + templatable =False + + def call(self): + skipmeta = int(self.req.form.get('skipmeta', True)) + self.visit_schemaOWL(display_relations=True, + skiprels=('is', 'is_instance_of', 'identity', + 'owned_by', 'created_by'), + skipmeta=skipmeta) + + + def visit_schemaOWL(self, display_relations=0, + skiprels=(), skipmeta=True): + """get a layout for a whole schema""" + self.w(u''' + + + + + + + ]> + + + + + %s Cubicweb OWL Ontology + + + + ''' % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name)) + entities = [eschema for eschema in self.schema.entities() + if not eschema.is_final()] + if skipmeta: + entities = [eschema for eschema in entities + if not eschema.meta] + keys = [(eschema.type, eschema) for eschema in entities] + self.w(u'') + for key, eschema in sorted(keys): + self.visit_entityschemaOWL(eschema, skiprels) + self.w(u'') + self.w(u'') + for key, eschema in sorted(keys): + self.visit_property_schemaOWL(eschema, skiprels) + self.w(u'') + for key, eschema in sorted(keys): + self.visit_property_object_schemaOWL(eschema, skiprels) + self.w(u'') + + def eschema_link_url(self, eschema): + return self.req.build_url('eetype/%s?vid=eschema' % eschema) + + def rschema_link_url(self, rschema): + return self.req.build_url('ertype/%s?vid=eschema' % rschema) + + def possible_views(self, etype): + rset = self.req.etype_rset(etype) + return [v for v in self._possible_views(self.req, rset) + if v.category != 'startupview'] + + def stereotype(self, name): + return Span((' <<%s>>' % name,), klass='stereotype') + + def visit_entityschemaOWL(self, eschema, skiprels=()): + """get a layout for an entity OWL schema""" + etype = eschema.type + + if eschema.meta: + self.stereotype('meta') + self.w(u''' + '''%eschema, stereotype) + else: + self.w(u''' + '''% eschema) + + self.w(u'') + for rschema, targetschemas, role in eschema.relation_definitions(): + if rschema.type in skiprels: + continue + if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): + continue + for oeschema in targetschemas: + label = rschema.type + if role == 'subject': + card = rschema.rproperty(eschema, oeschema, 'cardinality')[0] + else: + card = rschema.rproperty(oeschema, eschema, 'cardinality')[1] + self.w(u''' + + + %s + + + ''' % (label, OWL_CARD_MAP[card])) + + self.w(u'') + + for rschema, aschema in eschema.attribute_definitions(): + if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): + continue + aname = rschema.type + if aname == 'eid': + continue + card_data = aschema.type + self.w(u''' + + + + + ''' + + % aname) + self.w(u'') + + def visit_property_schemaOWL(self, eschema, skiprels=()): + """get a layout for property entity OWL schema""" + etype = eschema.type + + for rschema, targetschemas, role in eschema.relation_definitions(): + if rschema.type in skiprels: + continue + if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): + continue + rschemaurl = self.rschema_link_url(rschema) + for oeschema in targetschemas: + label = rschema.type + self.w(u''' + + + + + ''' % (label, eschema, oeschema.type )) + + def visit_property_object_schemaOWL(self, eschema, skiprels=()): + + for rschema, aschema in eschema.attribute_definitions(): + if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): + continue + aname = rschema.type + if aname == 'eid': + continue + card_data = aschema.type + self.w(u''' + + + ''' + % (aname, eschema, OWL_CARD_MAP_DATA[card_data])) + + diff -r 75d242975792 -r 1158231e7360 web/views/treeview.py --- a/web/views/treeview.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/views/treeview.py Fri Jan 23 19:21:29 2009 +0100 @@ -9,8 +9,9 @@ class TreeView(EntityView): id = 'treeview' accepts = ('Any',) - fstree = False itemvid = 'treeitemview' + css_classes = 'treeview widget' + title = _('tree view') def call(self, subvid=None): if subvid is None and 'subvid' in self.req.form: @@ -19,17 +20,14 @@ subvid = 'oneline' self.req.add_css('jquery.treeview.css') self.req.add_js(('cubicweb.ajax.js', 'jquery.treeview.js', 'cubicweb.widgets.js')) - css_classes = 'treeview widget' - if self.fstree: - css_classes += ' filetree' # XXX noautoload is a quick hack to avoid treeview to be rebuilt # after a json query and avoid double toggling bugs. # Need to find a way to do that cleanly. if 'noautoload' in self.req.form: - self.w(u'
    ' % css_classes) + self.w(u'
      ' % self.css_classes) else: self.w(u'
        ' - % css_classes) + % self.css_classes) for rowidx in xrange(len(self.rset)): self.wview(self.itemvid, self.rset, row=rowidx, col=0, vid=subvid, parentvid=self.id) @@ -40,14 +38,15 @@ """specific version of the treeview to display file trees """ id = 'filetree' - fstree = True + css_classes = 'treeview widget filetree' + title = _('file tree view') def call(self, subvid=None): super(FileTreeView, self).call(subvid='filetree-oneline') -class FileItemInnerView(OneLineView): +class FileItemInnerView(EntityView): """inner view used by the TreeItemView instead of oneline view This view adds an enclosing with some specific CSS classes diff -r 75d242975792 -r 1158231e7360 web/webconfig.py --- a/web/webconfig.py Fri Jan 23 19:18:28 2009 +0100 +++ b/web/webconfig.py Fri Jan 23 19:21:29 2009 +0100 @@ -1,7 +1,7 @@ """common web configuration for twisted/modpython applications :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -349,6 +349,6 @@ stream.close() def static_file_del(self, rpath): - if static_file_exists(rpath): + if self.static_file_exists(rpath): os.remove(join(self.static_directory, rpath))