# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1240906268 -7200 # Node ID 8270580b65a01431465f5a3d059f0c5f1fd49a81 # Parent 53d28ac028685f38a66c6abc2dd3ff2d24c43f33 delete-trailing-whitespaces diff -r 53d28ac02868 -r 8270580b65a0 cwconfig.py --- a/cwconfig.py Tue Apr 28 10:10:50 2009 +0200 +++ b/cwconfig.py Tue Apr 28 10:11:08 2009 +0200 @@ -4,6 +4,11 @@ :organization: Logilab :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr + +.. envvar:: CW_CUBES_PATH + + Augments the default search path for cubes + """ __docformat__ = "restructuredtext en" diff -r 53d28ac02868 -r 8270580b65a0 entities/__init__.py --- a/entities/__init__.py Tue Apr 28 10:10:50 2009 +0200 +++ b/entities/__init__.py Tue Apr 28 10:11:08 2009 +0200 @@ -23,7 +23,7 @@ """an entity instance has e_schema automagically set on the class and instances have access to their issuing cursor """ - id = 'Any' + id = 'Any' __implements__ = (IBreadCrumbs, IFeed) @classmethod @@ -38,7 +38,7 @@ usercls.id = etype usercls.__initialize__() return usercls - + fetch_attrs = ('modification_date',) @classmethod def fetch_order(cls, attr, var): @@ -46,7 +46,7 @@ this type are fetched """ return cls.fetch_unrelated_order(attr, var) - + @classmethod def fetch_unrelated_order(cls, attr, var): """class method used to control sort order when multiple entities of @@ -58,7 +58,7 @@ return None @classmethod - def __initialize__(cls): + def __initialize__(cls): super(ANYENTITY, cls).__initialize__() # XXX # set a default_ATTR method for rich text format fields # XXX move this away once the old widgets have been dropped! @@ -66,7 +66,7 @@ for metaattr, (metadata, attr) in eschema.meta_attributes().iteritems(): if metadata == 'format' and not hasattr(cls, 'default_%s' % metaattr): setattr(cls, 'default_%s' % metaattr, cls._default_format) - + # meta data api ########################################################### def dc_title(self): @@ -84,7 +84,7 @@ def dc_long_title(self): """return a more detailled title for this entity""" return self.dc_title() - + def dc_description(self, format='text/plain'): """return a suitable description for this entity""" if self.e_schema.has_subject_relation('description'): @@ -121,7 +121,7 @@ 'internationalizable'): return self.req._(self.req.user.property_value('ui.language')) return self.req._(self.vreg.property_value('ui.language')) - + @property def creator(self): """return the CWUser entity which has created this entity, or None if @@ -157,9 +157,9 @@ def rss_feed_url(self): return self.absolute_url(vid='rss') - + # abstractions making the whole things (well, some at least) working ###### - + def sortvalue(self, rtype=None): """return a value which can be used to sort this entity or given entity's attribute @@ -172,7 +172,7 @@ return self.printable_value(rtype, format='text/plain').lower() return value - # edition helper functions ################################################ + # edition helper functions ################################################ def linked_to(self, rtype, target, remove=True): """if entity should be linked to another using __linkto form param for @@ -200,9 +200,9 @@ linkedto.append(typed_eid(eid)) self.__linkto[(rtype, target)] = linkedto return linkedto - + # edit controller callbacks ############################################### - + def after_deletion_path(self): """return (path, parameters) which should be used as redirect information when this entity is being deleted @@ -216,20 +216,20 @@ Do nothing by default. """ pass - + # server side helpers ##################################################### - + def notification_references(self, view): """used to control References field of email send on notification for this entity. `view` is the notification view. - + Should return a list of eids which can be used to generate message ids of previously sent email """ return () - + # XXX deprecates, may be killed once old widgets system is gone ########### - + @classmethod def get_widget(cls, rschema, x='subject'): """return a widget to view or edit a relation @@ -258,7 +258,7 @@ def object_relation_vocabulary(self, rtype, limit): from cubicweb.web.form import EntityFieldsForm return EntityFieldsForm(self.req, None, entity=self).object_relation_vocabulary(rtype, limit) - + @obsolete('use AutomaticEntityForm.[e]relations_by_category') def relations_by_category(self, categories=None, permission=None): from cubicweb.web.views.editforms import AutomaticEntityForm @@ -268,10 +268,10 @@ def srelations_by_category(self, categories=None, permission=None): from cubicweb.web.views.editforms import AutomaticEntityForm return AutomaticEntityForm.esrelations_by_category(self, categories, permission) - + def _default_format(self): return self.req.property_value('ui.default-text-format') - + def attribute_values(self, attrname): if self.has_eid() or attrname in self: try: diff -r 53d28ac02868 -r 8270580b65a0 web/box.py --- a/web/box.py Tue Apr 28 10:10:50 2009 +0200 +++ b/web/box.py Tue Apr 28 10:11:08 2009 +0200 @@ -24,13 +24,13 @@ class BoxTemplate(View): """base template for boxes, usually a (contextual) list of possible - + actions. Various classes attributes may be used to control the box rendering. - + You may override on of the formatting callbacks is this is not necessary for your custom box. - + Classes inheriting from this class usually only have to override call to fetch desired actions, and then to do something like :: @@ -39,7 +39,7 @@ __registry__ = 'boxes' __select__ = match_context_prop() registered = classmethod(require_group_compat(View.registered)) - + categories_in_order = () property_defs = { _('visible'): dict(type='Boolean', default=True, @@ -76,9 +76,9 @@ if escape: title = html_escape(title) return self.box_action(self._action(title, path, **kwargs)) - + def _action(self, title, path, **kwargs): - return UnregisteredAction(self.req, self.rset, title, path, **kwargs) + return UnregisteredAction(self.req, self.rset, title, path, **kwargs) # formating callbacks @@ -91,12 +91,12 @@ cls = getattr(action, 'html_class', lambda: None)() or self.htmlitemclass return BoxLink(action.url(), self.req._(action.title), cls, self.boxitem_link_tooltip(action)) - + class RQLBoxTemplate(BoxTemplate): """abstract box for boxes displaying the content of a rql query not related to the current result set. - + It rely on etype, rtype (both optional, usable to control registration according to application schema and display according to connected user's rights) and rql attributes @@ -104,11 +104,11 @@ #XXX __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,) rql = None - + def to_display_rql(self): assert self.rql is not None, self.id return (self.rql,) - + def call(self, **kwargs): try: rset = self.req.execute(*self.to_display_rql()) @@ -123,7 +123,7 @@ box.append(self.mk_action(tname, entity.absolute_url())) box.render(w=self.w) - + class UserRQLBoxTemplate(RQLBoxTemplate): """same as rql box template but the rql is build using the eid of the request's user @@ -132,14 +132,14 @@ def to_display_rql(self): assert self.rql is not None, self.id return (self.rql, {'x': self.req.user.eid}, 'x') - + class EntityBoxTemplate(BoxTemplate): """base class for boxes related to a single entity""" __select__ = BoxTemplate.__select__ & one_line_rset() & primary_view() registered = accepts_compat(has_relation_compat(condition_compat(BoxTemplate.registered))) context = 'incontext' - + def call(self, row=0, col=0, **kwargs): """classes inheriting from EntityBoxTemplate should define cell_call""" self.cell_call(row, col, **kwargs) @@ -165,7 +165,7 @@ subclasses should define at least id, rtype and target class attributes. """ - + def cell_call(self, row, col, view=None): self.req.add_js('cubicweb.ajax.js') entity = self.entity(row, col) @@ -178,7 +178,7 @@ def div_id(self): return self.id - + def box_item(self, entity, etarget, rql, label): """builds HTML link to edit relation between `entity` and `etarget` """ @@ -189,7 +189,7 @@ label = u'[%s] %s' % (url, label, etarget.view('incontext')) return RawBoxItem(label, liclass=u'invisible') - + def w_related(self, box, entity): """appends existing relations to the `box`""" rql = 'DELETE S %s O WHERE S eid %%(s)s, O eid %%(o)s' % self.rtype @@ -197,7 +197,7 @@ for etarget in related: box.append(self.box_item(entity, etarget, rql, u'-')) return len(related) - + def w_unrelated(self, box, entity): """appends unrelated entities to the `box`""" rql = 'SET S %s O WHERE S eid %%(s)s, O eid %%(o)s' % self.rtype @@ -220,7 +220,7 @@ rset = self.req.eid_rset(eid) entities.append(rset.get_entity(0, 0)) return entities - + def related_entities(self, entity): return entity.related(self.rtype, get_role(self), entities=True)