author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Fri, 26 Jun 2009 13:51:37 +0200 | |
branch | stable |
changeset 2176 | 1ae46634bf8e |
parent 2175 | 16d3c37c5d28 (current diff) |
parent 2171 | b0c564c86a4b (diff) |
child 2177 | 3454adb6164a |
--- a/.hgtags Fri Jun 26 13:51:08 2009 +0200 +++ b/.hgtags Fri Jun 26 13:51:37 2009 +0200 @@ -41,3 +41,5 @@ 2d7d3062ca03d4b4144100013dc4ab7f9d9cb25e cubicweb-version-3_3_0 07214e923e75c8f0490e609e9bee0f4964b87114 cubicweb-debian-version-3_3_0-1 a356da3e725bfcb59d8b48a89d04be05ea261fd3 3.3.1 +e3aeb6e6c3bb5c18e8dcf61bae9d654beda6c036 cubicweb-version-3_3_2 +bef5e74e53f9de8220451dca4b5863a24a0216fb cubicweb-debian-version-3_3_2-1
--- a/__pkginfo__.py Fri Jun 26 13:51:08 2009 +0200 +++ b/__pkginfo__.py Fri Jun 26 13:51:37 2009 +0200 @@ -7,7 +7,7 @@ distname = "cubicweb" modname = "cubicweb" -numversion = (3, 3, 1) +numversion = (3, 3, 2) version = '.'.join(str(num) for num in numversion) license = 'LGPL v2'
--- a/cwctl.py Fri Jun 26 13:51:08 2009 +0200 +++ b/cwctl.py Fri Jun 26 13:51:37 2009 +0200 @@ -141,7 +141,7 @@ if forkcmd: status = system('%s %s' % (forkcmd, appid)) if status: - sys.exit(status) + print '%s exited with status %s' % (forkcmd, status) else: self.run_arg(appid)
--- a/debian/changelog Fri Jun 26 13:51:08 2009 +0200 +++ b/debian/changelog Fri Jun 26 13:51:37 2009 +0200 @@ -1,3 +1,9 @@ +cubicweb (3.3.2-1) unstable; urgency=low + + * new upstream release + + -- Sylvain Thénault <sylvain.thenault@logilab.fr> Thu, 25 Jun 2009 07:58:14 +0200 + cubicweb (3.3.1-1) unstable; urgency=low * new upstream release
--- a/etwist/server.py Fri Jun 26 13:51:08 2009 +0200 +++ b/etwist/server.py Fri Jun 26 13:51:37 2009 +0200 @@ -138,6 +138,9 @@ if segments[0] == 'static': # instance static directory datadir = self.config.static_directory + elif segments[1] == 'fckeditor': + fckeditordir = self.config.ext_resources['FCKEDITOR_PATH'] + return static.File(fckeditordir), segments[2:] else: # cube static data file datadir = self.config.locate_resource(segments[1])
--- a/schema.py Fri Jun 26 13:51:08 2009 +0200 +++ b/schema.py Fri Jun 26 13:51:37 2009 +0200 @@ -32,8 +32,6 @@ schema.use_py_datetime() nodes.use_py_datetime() -_ = unicode - BASEGROUPS = ('managers', 'users', 'guests', 'owners') _LOGGER = getLogger('cubicweb.schemaloader')
--- a/selectors.py Fri Jun 26 13:51:08 2009 +0200 +++ b/selectors.py Fri Jun 26 13:51:37 2009 +0200 @@ -189,7 +189,7 @@ self.once_is_enough = once_is_enough @lltrace - def __call__(self, cls, req, rset, row=None, col=0, **kwargs): + def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs): if not rset: return 0 score = 0 @@ -238,7 +238,7 @@ """ @lltrace - def __call__(self, cls, req, rset, row=None, col=0, **kwargs): + def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs): if not rset and not kwargs.get('entity'): return 0 score = 0 @@ -287,7 +287,7 @@ @objectify_selector @lltrace -def none_rset(cls, req, rset, *args, **kwargs): +def none_rset(cls, req, rset=None, *args, **kwargs): """accept no result set (e.g. given rset is None)""" if rset is None: return 1 @@ -295,7 +295,7 @@ @objectify_selector @lltrace -def any_rset(cls, req, rset, *args, **kwargs): +def any_rset(cls, req, rset=None, *args, **kwargs): """accept result set, whatever the number of result it contains""" if rset is not None: return 1 @@ -303,7 +303,7 @@ @objectify_selector @lltrace -def nonempty_rset(cls, req, rset, *args, **kwargs): +def nonempty_rset(cls, req, rset=None, *args, **kwargs): """accept any non empty result set""" if rset is not None and rset.rowcount: return 1 @@ -311,7 +311,7 @@ @objectify_selector @lltrace -def empty_rset(cls, req, rset, *args, **kwargs): +def empty_rset(cls, req, rset=None, *args, **kwargs): """accept empty result set""" if rset is not None and rset.rowcount == 0: return 1 @@ -319,7 +319,7 @@ @objectify_selector @lltrace -def one_line_rset(cls, req, rset, row=None, *args, **kwargs): +def one_line_rset(cls, req, rset=None, row=None, *args, **kwargs): """if row is specified, accept result set with a single line of result, else accepts anyway """ @@ -329,7 +329,7 @@ @objectify_selector @lltrace -def two_lines_rset(cls, req, rset, *args, **kwargs): +def two_lines_rset(cls, req, rset=None, *args, **kwargs): """accept result set with *at least* two lines of result""" if rset is not None and rset.rowcount > 1: return 1 @@ -337,7 +337,7 @@ @objectify_selector @lltrace -def two_cols_rset(cls, req, rset, *args, **kwargs): +def two_cols_rset(cls, req, rset=None, *args, **kwargs): """accept result set with at least one line and two columns of result""" if rset is not None and rset.rowcount and len(rset.rows[0]) > 1: return 1 @@ -345,7 +345,7 @@ @objectify_selector @lltrace -def paginated_rset(cls, req, rset, *args, **kwargs): +def paginated_rset(cls, req, rset=None, *args, **kwargs): """accept result set with more lines than the page size. Page size is searched in (respecting order): @@ -366,7 +366,7 @@ @objectify_selector @lltrace -def sorted_rset(cls, req, rset, row=None, col=0, **kwargs): +def sorted_rset(cls, req, rset=None, row=None, col=0, **kwargs): """accept sorted result set""" rqlst = rset.syntax_tree() if len(rqlst.children) > 1 or not rqlst.children[0].orderby: @@ -375,7 +375,7 @@ @objectify_selector @lltrace -def one_etype_rset(cls, req, rset, row=None, col=0, *args, **kwargs): +def one_etype_rset(cls, req, rset=None, row=None, col=0, *args, **kwargs): """accept result set where entities in the specified column (or 0) are all of the same type """ @@ -387,7 +387,7 @@ @objectify_selector @lltrace -def two_etypes_rset(cls, req, rset, row=None, col=0, **kwargs): +def two_etypes_rset(cls, req, rset=None, row=None, col=0, **kwargs): """accept result set where entities in the specified column (or 0) are not of the same type """ @@ -420,7 +420,7 @@ @objectify_selector @lltrace -def primary_view(cls, req, rset, row=None, col=0, view=None, **kwargs): +def primary_view(cls, req, rset=None, row=None, col=0, view=None, **kwargs): """accept if view given as named argument is a primary view, or if no view is given """ @@ -430,7 +430,7 @@ @objectify_selector @lltrace -def match_context_prop(cls, req, rset, row=None, col=0, context=None, +def match_context_prop(cls, req, rset=None, row=None, col=0, context=None, **kwargs): """accept if: * no context given @@ -461,7 +461,7 @@ ','.join(sorted(str(s) for s in self.expected))) @lltrace - def __call__(self, cls, req, rset, row=None, col=0, **kwargs): + def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs): try: if not req.search_state[0] in self.expected: return 0 @@ -554,7 +554,7 @@ initializer """ @lltrace - def __call__(self, cls, req, rset, row=None, col=0, view=None, **kwargs): + def __call__(self, cls, req, rset=None, row=None, col=0, view=None, **kwargs): if view is None or not view.id in self.expected: return 0 return 1 @@ -571,7 +571,7 @@ self.registry = registry self.oid = oid - def __call__(self, cls, req, rset, *args, **kwargs): + def __call__(self, cls, req, rset=None, *args, **kwargs): try: cls.vreg.select_object(self.registry, self.oid, req, rset, *args, **kwargs) return 1 @@ -850,7 +850,7 @@ self.action = action @lltrace - def __call__(self, cls, req, rset, row=None, col=0, **kwargs): + def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs): if rset is None: return 0 user = req.user @@ -985,11 +985,11 @@ primaryview_selector = deprecated_function(primary_view) contextprop_selector = deprecated_function(match_context_prop) -def nfentity_selector(cls, req, rset, row=None, col=0, **kwargs): +def nfentity_selector(cls, req, rset=None, row=None, col=0, **kwargs): return non_final_entity()(cls, req, rset, row, col) nfentity_selector = deprecated_function(nfentity_selector) -def implement_interface(cls, req, rset, row=None, col=0, **kwargs): +def implement_interface(cls, req, rset=None, row=None, col=0, **kwargs): return implements(*cls.accepts_interfaces)(cls, req, rset, row, col) _interface_selector = deprecated_function(implement_interface) interface_selector = deprecated_function(implement_interface) @@ -1001,7 +1001,7 @@ etype_form_selector = deprecated_function(accept_etype) accept_etype = deprecated_function(accept_etype, 'use specified_etype_implements') -def searchstate_selector(cls, req, rset, row=None, col=0, **kwargs): +def searchstate_selector(cls, req, rset=None, row=None, col=0, **kwargs): return match_search_state(cls.search_states)(cls, req, rset, row, col) searchstate_selector = deprecated_function(searchstate_selector) @@ -1010,18 +1010,18 @@ in_group_selector = deprecated_function(match_user_group) match_user_group = deprecated_function(match_user_group) -def has_relation(cls, req, rset, row=None, col=0, **kwargs): +def has_relation(cls, req, rset=None, row=None, col=0, **kwargs): return relation_possible(cls.rtype, role(cls), cls.etype, getattr(cls, 'require_permission', 'read'))(cls, req, rset, row, col, **kwargs) has_relation = deprecated_function(has_relation) -def one_has_relation(cls, req, rset, row=None, col=0, **kwargs): +def one_has_relation(cls, req, rset=None, row=None, col=0, **kwargs): return relation_possible(cls.rtype, role(cls), cls.etype, getattr(cls, 'require_permission', 'read', once_is_enough=True))(cls, req, rset, row, col, **kwargs) one_has_relation = deprecated_function(one_has_relation, 'use relation_possible selector') -def accept_rset(cls, req, rset, row=None, col=0, **kwargs): +def accept_rset(cls, req, rset=None, row=None, col=0, **kwargs): """simply delegate to cls.accept_rset method""" return implements(*cls.accepts)(cls, req, rset, row=row, col=col) accept_rset_selector = deprecated_function(accept_rset) @@ -1036,7 +1036,7 @@ accept_one_selector = deprecated_function(accept_one) -def _rql_condition(cls, req, rset, row=None, col=0, **kwargs): +def _rql_condition(cls, req, rset=None, row=None, col=0, **kwargs): if cls.condition: return rql_condition(cls.condition)(cls, req, rset, row, col) return 1 @@ -1045,12 +1045,12 @@ rqlcondition_selector = deprecated_function(chainall(non_final_entity(), one_line_rset, _rql_condition, name='rql_condition')) -def but_etype_selector(cls, req, rset, row=None, col=0, **kwargs): +def but_etype_selector(cls, req, rset=None, row=None, col=0, **kwargs): return but_etype(cls.etype)(cls, req, rset, row, col) but_etype_selector = deprecated_function(but_etype_selector) @lltrace -def etype_rtype_selector(cls, req, rset, row=None, col=0, **kwargs): +def etype_rtype_selector(cls, req, rset=None, row=None, col=0, **kwargs): schema = cls.schema perm = getattr(cls, 'require_permission', 'read') if hasattr(cls, 'etype'):
--- a/server/msplanner.py Fri Jun 26 13:51:08 2009 +0200 +++ b/server/msplanner.py Fri Jun 26 13:51:37 2009 +0200 @@ -553,6 +553,14 @@ # NOTE: < 2 since may be 0 on queries such as Any X WHERE X eid 2 if len(self._sourcesterms) < 2: self.needsplit = False + # if this is not the system source but we have only constant terms + # and no relation (other than eid), apply query on the system source + # + # testing for rqlst with nothing in vargraph nor defined_vars is the + # simplest way the check the condition explained below + if not self.system_source in self._sourcesterms and \ + not self.rqlst.vargraph and not self.rqlst.defined_vars: + self._sourcesterms = {self.system_source: {}} elif not self.needsplit: if not allequals(self._sourcesterms.itervalues()): for terms in self._sourcesterms.itervalues():
--- a/server/repository.py Fri Jun 26 13:51:08 2009 +0200 +++ b/server/repository.py Fri Jun 26 13:51:37 2009 +0200 @@ -209,11 +209,6 @@ # initialized) for source in self.sources: source.init() - # call application level initialisation hooks - self.hm.call_hooks('server_startup', repo=self) - # register a task to cleanup expired session - self.looping_task(self.config['session-time']/3., - self.clean_sessions) else: # call init_creating so for instance native source can configurate # tsearch according to postgres version @@ -225,6 +220,12 @@ for i in xrange(config['connections-pool-size']): self._available_pools.put_nowait(ConnectionsPool(self.sources)) self._shutting_down = False + if not config.creating: + # call application level initialisation hooks + self.hm.call_hooks('server_startup', repo=self) + # register a task to cleanup expired session + self.looping_task(self.config['session-time']/3., + self.clean_sessions) # internals ###############################################################
--- a/server/test/unittest_msplanner.py Fri Jun 26 13:51:08 2009 +0200 +++ b/server/test/unittest_msplanner.py Fri Jun 26 13:51:37 2009 +0200 @@ -2072,6 +2072,14 @@ )], {'x': 999999}) + def test_nonregr_eid_query(self): + self.repo._type_source_cache[999999] = ('Note', 'cards', 999999) + self._test('Any X WHERE X eid 999999', + [('OneFetchStep', [('Any 999999', [{}])], + None, None, [self.system], {}, [] + )], + {'x': 999999}) + class FakeVCSSource(AbstractSource):
--- a/skeleton/__pkginfo__.py.tmpl Fri Jun 26 13:51:08 2009 +0200 +++ b/skeleton/__pkginfo__.py.tmpl Fri Jun 26 13:51:37 2009 +0200 @@ -17,16 +17,16 @@ short_desc = '%(shortdesc)s' long_desc = '''%(longdesc)s''' -from os import listdir as _listdir -from os.path import join, isdir - web = 'http://www.cubicweb.org/project/%%s' %% distname pyversions = ['2.4'] -#from cubicweb.devtools.pkginfo import get_distutils_datafiles -CUBES_DIR = join('share', 'cubicweb', 'cubes') -THIS_CUBE_DIR = join(CUBES_DIR, '%(cubename)s') + +from os import listdir as _listdir +from os.path import join, isdir, exists, dirname +from glob import glob + +THIS_CUBE_DIR = join('share', 'cubicweb', 'cubes', modname) def listdir(dirpath): return [join(dirpath, fname) for fname in _listdir(dirpath) @@ -34,12 +34,11 @@ and not fname.endswith('~') and not isdir(join(dirpath, fname))] -from glob import glob try: data_files = [ # common files [THIS_CUBE_DIR, [fname for fname in glob('*.py') if fname != 'setup.py']], - ] + ] # check for possible extended cube layout for dirname in ('entities', 'views', 'sobjects', 'hooks', 'schema', 'data', 'i18n', 'migration'): if isdir(dirname): @@ -47,8 +46,9 @@ # Note: here, you'll need to add subdirectories if you want # them to be included in the debian package except OSError: + if exists(dirname(__file__)): + raise # we are in an installed directory - pass cube_eid = None # <=== FIXME if you need direct bug-subscription
--- a/web/box.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/box.py Fri Jun 26 13:51:37 2009 +0200 @@ -6,6 +6,7 @@ :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses """ __docformat__ = "restructuredtext en" +_ = unicode from logilab.mtconverter import html_escape @@ -20,8 +21,6 @@ RawBoxItem, BoxSeparator) from cubicweb.web.action import UnregisteredAction -_ = unicode - class BoxTemplate(View): """base template for boxes, usually a (contextual) list of possible
--- a/web/data/cubicweb.preferences.js Fri Jun 26 13:51:08 2009 +0200 +++ b/web/data/cubicweb.preferences.js Fri Jun 26 13:51:37 2009 +0200 @@ -114,36 +114,37 @@ function setCurrentValues(form){ jQuery(form).find('[name^=value]').each(function () { - var input = jQuery(this); - var name = input.attr('name'); - if(input.attr('type') == 'radio'){ - // NOTE: there seems to be a bug with jQuery(input).attr('checked') - // in our case, we can't rely on its value, we use - // the DOM API instead. - if(input[0].checked){ - prefsValues[name] = input.val(); - } - }else{ + var input = jQuery(this); + var name = input.attr('name'); + if(input.attr('type') == 'radio'){ + // NOTE: there seems to be a bug with jQuery(input).attr('checked') + // in our case, we can't rely on its value, we use + // the DOM API instead. + if(input[0].checked){ prefsValues[name] = input.val(); } - jQuery('[name=edits-'+ name + ']').val(prefsValues[name]); - }); + }else{ + prefsValues[name] = input.val(); + } + jQuery(form).find('input[name=edits-'+ name + ']').val(prefsValues[name]); + }); } function initEvents(){ - jQuery('form').each(function() { - var form = jQuery(this); - freezeFormButtons(form.attr('id')); - form.find('input[type=text]').keyup(function(){ - checkValues(form); - }); - form.find('input[type=radio]').change(function(){ - checkValues(form); - }); - form.find('select').change(function(){ - checkValues(form); - }); - setCurrentValues(form); + jQuery('form').each(function() { + var form = jQuery(this); + //freezeFormButtons(form.attr('id')); + form.find('input.validateButton').attr('disabled', 'disabled'); + form.find('input[type=text]').keyup(function(){ + checkValues(form); + }); + form.find('input[type=radio]').change(function(){ + checkValues(form); + }); + form.find('select').change(function(){ + checkValues(form); + }); + setCurrentValues(form); }); }
--- a/web/views/actions.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/views/actions.py Fri Jun 26 13:51:37 2009 +0200 @@ -40,11 +40,11 @@ return 0 @objectify_selector -def match_searched_etype(cls, req, rset, **kwargs): +def match_searched_etype(cls, req, rset=None, **kwargs): return req.match_search_state(rset) @objectify_selector -def view_is_not_default_view(cls, req, rset, **kwargs): +def view_is_not_default_view(cls, req, rset=None, **kwargs): # interesting if it propose another view than the current one vid = req.form.get('vid') if vid and vid != vid_from_rset(req, rset, cls.schema): @@ -52,7 +52,7 @@ return 0 @objectify_selector -def addable_etype_empty_rset(cls, req, rset, **kwargs): +def addable_etype_empty_rset(cls, req, rset=None, **kwargs): if rset is not None and not rset.rowcount: rqlst = rset.syntax_tree() if len(rqlst.children) > 1:
--- a/web/views/cwproperties.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/views/cwproperties.py Fri Jun 26 13:51:37 2009 +0200 @@ -14,7 +14,7 @@ from cubicweb import UnknownProperty from cubicweb.selectors import (one_line_rset, none_rset, implements, - match_user_groups) + match_user_groups, objectify_selector) from cubicweb.view import StartupView from cubicweb.web import uicfg, stdmsgs from cubicweb.web.form import FormViewMixIn @@ -218,8 +218,10 @@ subform.form_add_hidden('pkey', key, eidparam=True) form.form_add_subform(subform) return subform - -def is_user_prefs(cls, req, rset, row=None, col=0, **kwargs): + + +@objectify_selector +def is_user_prefs(cls, req, rset=None, row=None, col=0, **kwargs): return req.user.eid == rset[row or 0][col] @@ -228,7 +230,7 @@ __select__ = ( # we don't want guests to be able to come here match_user_groups('users', 'managers') & - (none_rset() | ((one_line_rset() & is_user_prefs) & + (none_rset() | ((one_line_rset() & is_user_prefs()) & (one_line_rset() & match_user_groups('managers')))) )
--- a/web/views/emailaddress.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/views/emailaddress.py Fri Jun 26 13:51:37 2009 +0200 @@ -99,18 +99,17 @@ if entity.reverse_primary_email: self.w(u'<b>') if entity.alias: - mailto = u'%s <%s>' % (entity.alias, entity.display_address()) + alias = entity.alias elif entity.reverse_use_email: - mailto = "mailto:%s <%s>" % \ - (entity.reverse_use_email[0].dc_title(), - entity.display_address()) + alias = entity.reverse_use_email[0].dc_title() + else: + alias = None + if alias: + mailto = "mailto:%s <%s>" % (alias, entity.display_address()) else: mailto = "mailto:%s" % entity.display_address() self.w(u'<a href="%s">%s</a>' % (html_escape(mailto), html_escape(entity.display_address()))) - - if entity.alias: - self.w(u'>\n') if entity.reverse_primary_email: self.w(u'</b>')
--- a/web/views/facets.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/views/facets.py Fri Jun 26 13:51:37 2009 +0200 @@ -19,7 +19,7 @@ prepare_facets_rqlst, filter_hiddens) @objectify_selector -def contextview_selector(cls, req, rset, row=None, col=None, view=None, +def contextview_selector(cls, req, rset=None, row=None, col=None, view=None, **kwargs): if view and getattr(view, 'filter_box_context_info', lambda: None)(): return 1
--- a/web/views/plots.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/views/plots.py Fri Jun 26 13:51:37 2009 +0200 @@ -20,13 +20,13 @@ from cubicweb.web.views import baseviews @objectify_selector -def at_least_two_columns(cls, req, rset, *args, **kwargs): +def at_least_two_columns(cls, req, rset=None, *args, **kwargs): if not rset: return 0 return len(rset.rows[0]) >= 2 @objectify_selector -def all_columns_are_numbers(cls, req, rset, *args, **kwargs): +def all_columns_are_numbers(cls, req, rset=None, *args, **kwargs): """accept result set with at least one line and two columns of result all columns after second must be of numerical types""" for etype in rset.description[0]: @@ -35,14 +35,14 @@ return 1 @objectify_selector -def second_column_is_number(cls, req, rset, *args, **kwargs): +def second_column_is_number(cls, req, rset=None, *args, **kwargs): etype = rset.description[0][1] if etype not in ('Int', 'Float'): return 0 return 1 @objectify_selector -def columns_are_date_then_numbers(cls, req, rset, *args, **kwargs): +def columns_are_date_then_numbers(cls, req, rset=None, *args, **kwargs): etypes = rset.description[0] if etypes[0] not in ('Date', 'Datetime'): return 0
--- a/web/views/primary.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/views/primary.py Fri Jun 26 13:51:37 2009 +0200 @@ -57,7 +57,9 @@ self.content_navigation_components('navcontenttop') try: self.render_entity_attributes(entity) - except TypeError: # XXX bw compat + except TypeError, e: # XXX bw compat + if 'render_entity' not in e.args[0]: + raise warn('siderelations argument of render_entity_attributes is ' 'deprecated (%s)' % self.__class__) self.render_entity_attributes(entity, []) @@ -66,6 +68,8 @@ try: self.render_entity_relations(entity) except TypeError: # XXX bw compat + if 'render_entity' not in e.args[0]: + raise warn('siderelations argument of render_entity_relations is ' 'deprecated') self.render_entity_relations(entity, [])
--- a/web/views/startup.py Fri Jun 26 13:51:08 2009 +0200 +++ b/web/views/startup.py Fri Jun 26 13:51:37 2009 +0200 @@ -177,6 +177,7 @@ self.w(u'<h1>%s</h1>' % _('Schema of the data model')) self.render_tabs(self.tabs, self.default_tab) + class SchemaTabImageView(StartupView): id = 'schema-image' @@ -189,6 +190,7 @@ html_escape(self.req.build_url('view', vid='schemagraph', withmeta=0)), self.req._("graphical representation of the application'schema"))) + class SchemaTabTextView(StartupView): id = 'schema-text' @@ -205,11 +207,12 @@ class ManagerSchemaPermissionsView(StartupView, SecurityViewMixIn): - id = 'schema_security' + id = 'schema-security' __select__ = StartupView.__select__ & match_user_groups('managers') def call(self, display_relations=True, skiprels=('is', 'is_instance_of', 'identity', 'owned_by', 'created_by')): + self.req.add_css('cubicweb.acl.css') _ = self.req._ formparams = {} formparams['sec'] = self.id @@ -222,28 +225,31 @@ entities = [eschema for eschema in entities if not eschema.meta] # compute relations - relations = [] if display_relations: relations = [rschema for rschema in schema.relations() if not (rschema.is_final() or rschema.type in skiprels)] if not formparams['withmeta']: relations = [rschema for rschema in relations if not rschema.meta] + else: + relations = [] # index self.w(u'<div id="schema_security"><a id="index" href="index"/>') self.w(u'<h2 class="schema">%s</h2>' % _('index').capitalize()) self.w(u'<h4>%s</h4>' % _('Entities').capitalize()) ents = [] for eschema in sorted(entities): - url = html_escape(self.build_url('schema', **formparams) + '#' + eschema.type) - ents.append(u'<a class="grey" href="%s">%s</a> (%s)' % (url, eschema.type, _(eschema.type))) - self.w('%s' % ', '.join(ents)) + url = html_escape(self.build_url('schema', **formparams)) + ents.append(u'<a class="grey" href="%s#%s">%s</a> (%s)' % ( + url, eschema.type, eschema.type, _(eschema.type))) + self.w(u', '.join(ents)) self.w(u'<h4>%s</h4>' % (_('relations').capitalize())) rels = [] - for eschema in sorted(relations): - url = html_escape(self.build_url('schema', **formparams) + '#' + eschema.type) - rels.append(u'<a class="grey" href="%s">%s</a> (%s), ' % (url , eschema.type, _(eschema.type))) - self.w('%s' % ', '.join(ents)) + for rschema in sorted(relations): + url = html_escape(self.build_url('schema', **formparams)) + rels.append(u'<a class="grey" href="%s#%s">%s</a> (%s), ' % ( + url , rschema.type, rschema.type, _(rschema.type))) + self.w(u', '.join(ents)) # entities self.display_entities(entities, formparams) # relations