remove trailing white spaces tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 22 Apr 2009 18:44:30 +0200
branchtls-sprint
changeset 1433 091ac3ba5d51
parent 1432 2c3711d4570b
child 1434 42e57dbbc585
remove trailing white spaces
view.py
vregistry.py
web/action.py
web/component.py
web/controller.py
web/facet.py
web/views/magicsearch.py
web/views/urlrewrite.py
--- a/view.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/view.py	Wed Apr 22 18:44:30 2009 +0200
@@ -202,12 +202,12 @@
         self.req.set_content_type(self.content_type)
 
     # view utilities ##########################################################
-    
+
     def wview(self, __vid, rset, __fallback_vid=None, **kwargs):
         """shortcut to self.view method automatically passing self.w as argument
         """
         self.view(__vid, rset, __fallback_vid, w=self.w, **kwargs)
-        
+
     # XXX Template bw compat
     template = obsolete('.template is deprecated, use .view')(wview)
 
@@ -303,14 +303,14 @@
         w(u'<div class="field">%s</div>' % value)
         if row:
             w(u'</div>')
-            
+
     def initialize_varmaker(self):
         varmaker = self.req.get_page_data('rql_varmaker')
         if varmaker is None:
             varmaker = self.req.varmaker
             self.req.set_page_data('rql_varmaker', varmaker)
         self.varmaker = varmaker
-        
+
 
 
 # concrete views base classes #################################################
@@ -329,9 +329,9 @@
     """
     __select__ = none_rset()
     registered = require_group_compat(View.registered)
-    
+
     category = 'startupview'
-    
+
     def url(self):
         """return the url associated with this view. We can omit rql here"""
         return self.build_url('view', vid=self.id)
@@ -405,7 +405,7 @@
             labels.append(label)
         return labels
 
-    
+
 # concrete template base classes ##############################################
 
 class MainTemplate(View):
@@ -443,12 +443,12 @@
 
     def linkable(self):
         return False
-    
+
 # concrete component base classes #############################################
 
 class ReloadableMixIn(object):
     """simple mixin for reloadable parts of UI"""
-    
+
     def user_callback(self, cb, args, msg=None, nonify=False):
         """register the given user callback and return an url to call it ready to be
         inserted in html
@@ -460,17 +460,17 @@
                 _cb(*args)
         cbname = self.req.register_onetime_callback(cb, *args)
         return self.build_js(cbname, html_escape(msg or ''))
-        
+
     def build_update_js_call(self, cbname, msg):
         rql = html_escape(self.rset.printable_rql())
         return "javascript:userCallbackThenUpdateUI('%s', '%s', '%s', '%s', '%s', '%s')" % (
             cbname, self.id, rql, msg, self.__registry__, self.div_id())
-    
+
     def build_reload_js_call(self, cbname, msg):
         return "javascript:userCallbackThenReloadPage('%s', '%s')" % (cbname, msg)
 
     build_js = build_update_js_call # expect updatable component by default
-    
+
     def div_id(self):
         return ''
 
@@ -482,7 +482,7 @@
     property_defs = {
         _('visible'):  dict(type='Boolean', default=True,
                             help=_('display the component or not')),
-        }    
+        }
 
     def div_class(self):
         return '%s %s' % (self.propval('htmlclass'), self.id)
--- a/vregistry.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/vregistry.py	Wed Apr 22 18:44:30 2009 +0200
@@ -6,7 +6,7 @@
 
 * to interact with the vregistry, object should inherit from the
   VObject abstract class
-  
+
 * the selection procedure has been generalized by delegating to a
   selector, which is responsible to score the vobject according to the
   current state (req, rset, row, col). At the end of the selection, if
@@ -53,7 +53,7 @@
     registry.
 
     The following attributes should be set on concret vobject subclasses:
-    
+
     :__registry__:
       name of the registry for this object (string like 'views',
       'templates'...)
@@ -62,7 +62,7 @@
       'primary', 'folder_box')
     :__select__:
       class'selector
-      
+
     Moreover, the `__abstract__` attribute may be set to True to indicate
     that a vobject is abstract and should not be registered
     """
@@ -85,7 +85,7 @@
     @classmethod
     def selected(cls, *args, **kwargs):
         """called by the registry when the vobject has been selected.
-        
+
         It must return the  object that will be actually returned by the
         .select method (this may be the right hook to create an
         instance for example). By default the selected object is
@@ -127,7 +127,7 @@
     elements used to build the web interface. Currently, we have templates,
     views, actions and components.
     """
-    
+
     def __init__(self, config):#, cache_size=1000):
         self.config = config
         # dictionnary of registry (themself dictionnary) by name
@@ -199,7 +199,7 @@
                 continue
             if oid:
                 self.register(obj)
-                
+
     def register(self, obj, registryname=None, oid=None, clear=False):
         """base method to add an object in the registry"""
         assert not '__abstract__' in obj.__dict__
@@ -246,9 +246,9 @@
 #                 else:
 #                     # if objects is empty, remove oid from registry
 #                     if not registry[obj.id]:
-#                         del regcontent[oid]                    
+#                         del regcontent[oid]
                 break
-    
+
     def register_and_replace(self, obj, replaced, registryname=None):
         if hasattr(replaced, 'classid'):
             replaced = replaced.classid()
@@ -262,7 +262,7 @@
         self.register(obj, registryname=registryname)
 
     # dynamic selection methods ###############################################
-    
+
     def select(self, vobjects, *args, **kwargs):
         """return an instance of the most specific object according
         to parameters
@@ -291,7 +291,7 @@
         winner = winners[0]
         # return the result of the .selected method of the vobject
         return winner.selected(*args, **kwargs)
-    
+
     def possible_objects(self, registry, *args, **kwargs):
         """return an iterator on possible objects in a registry for this result set
 
@@ -306,15 +306,15 @@
     def select_object(self, registry, cid, *args, **kwargs):
         """return the most specific component according to the resultset"""
         return self.select(self.registry_objects(registry, cid), *args, **kwargs)
-    
+
     # intialization methods ###################################################
-    
+
     def init_registration(self, path):
         # compute list of all modules that have to be loaded
         self._toloadmods, filemods = _toload_info(path)
         self._loadedmods = {}
         return filemods
-    
+
     def register_objects(self, path, force_reload=None):
         if force_reload is None:
             force_reload = self.config.mode == 'dev'
@@ -341,7 +341,7 @@
             if self.load_file(filepath, modname, force_reload):
                 change = True
         return change
-    
+
     def load_file(self, filepath, modname, force_reload=False):
         """load visual objects from a python file"""
         from logilab.common.modutils import load_module_from_name
@@ -368,7 +368,7 @@
         module = load_module_from_name(modname, use_sys=not force_reload)
         self.load_module(module)
         # if something was unregistered, we need to update places where it was
-        # referenced 
+        # referenced
         if unregistered:
             # oldnew_mapping = {}
             registered = self._loadedmods[modname]
@@ -388,7 +388,7 @@
                     continue
                 self._load_ancestors_then_object(module.__name__, obj)
         self.debug('loaded %s', module)
-    
+
     def _load_ancestors_then_object(self, modname, obj):
         # imported classes
         objmodname = getattr(obj, '__module__', None)
@@ -409,7 +409,7 @@
         for parent in obj.__bases__:
             self._load_ancestors_then_object(modname, parent)
         self.load_object(obj)
-            
+
     def load_object(self, obj):
         try:
             self.register_vobject_class(obj)
@@ -417,12 +417,12 @@
             if self.config.mode in ('test', 'dev'):
                 raise
             self.exception('vobject %s registration failed: %s', obj, ex)
-        
+
     # old automatic registration XXX deprecated ###############################
-    
+
     def register_vobject_class(self, cls):
         """handle vobject class registration
-        
+
         vobject class with __abstract__ == True in their local dictionnary or
         with a name starting starting by an underscore are not registered.
         Also a vobject class needs to have __registry__ and id attributes set
@@ -435,7 +435,7 @@
         if '%s.%s' % (regname, cls.id) in self.config['disable-appobjects']:
             return
         self.register(cls)
-            
+
     def unregister_module_vobjects(self, modname):
         """removes registered objects coming from a given module
 
@@ -497,8 +497,8 @@
                         self.debug('updating %s.%s base classes',
                                   obj.__module__, obj.__name__)
                         obj.__bases__ = newbases
-        
-# init logging 
+
+# init logging
 set_log_methods(VObject, getLogger('cubicweb'))
 set_log_methods(VRegistry, getLogger('cubicweb.registry'))
 
@@ -537,7 +537,7 @@
 
     def __str__(self):
         return self.__class__.__name__
-    
+
     def __and__(self, other):
         return AndSelector(self, other)
     def __rand__(self, other):
@@ -550,7 +550,7 @@
 
     def __invert__(self):
         return NotSelector(self)
-    
+
     # XXX (function | function) or (function & function) not managed yet
 
     def __call__(self, cls, *args, **kwargs):
@@ -559,7 +559,7 @@
 
 class MultiSelector(Selector):
     """base class for compound selector classes"""
-    
+
     def __init__(self, *selectors):
         self.selectors = self.merge_selectors(selectors)
 
@@ -600,7 +600,7 @@
                 return found
         return None
 
-    
+
 def objectify_selector(selector_func):
     """convenience decorator for simple selectors where a class definition
     would be overkill::
@@ -608,14 +608,14 @@
         @objectify_selector
         def yes(cls, *args, **kwargs):
             return 1
-        
+
     """
     return type(selector_func.__name__, (Selector,),
                 {'__call__': lambda self, *args, **kwargs: selector_func(*args, **kwargs)})
 
 def _instantiate_selector(selector):
     """ensures `selector` is a `Selector` instance
-    
+
     NOTE: This should only be used locally in build___select__()
     XXX: then, why not do it ??
     """
--- a/web/action.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/web/action.py	Wed Apr 22 18:44:30 2009 +0200
@@ -17,11 +17,11 @@
 
 class Action(AppRsetObject):
     """abstract action. Handle the .search_states attribute to match
-    request search state. 
+    request search state.
     """
     __registry__ = 'actions'
     __select__ = yes()
-    
+
     property_defs = {
         'visible':  dict(type='Boolean', default=True,
                          help=_('display the action or not')),
@@ -34,11 +34,11 @@
     }
     site_wide = True # don't want user to configuration actions eproperties
     category = 'moreactions'
-    
+
     def url(self):
         """return the url associated with this action"""
         raise NotImplementedError
-    
+
     def html_class(self):
         if self.req.selected(self.url()):
             return 'selected'
@@ -52,13 +52,13 @@
     """
     category = None
     id = None
-    
+
     def __init__(self, req, rset, title, path, **kwargs):
         Action.__init__(self, req, rset)
         self.title = req._(title)
         self._path = path
         self.__dict__.update(kwargs)
-        
+
     def url(self):
         return self._path
 
@@ -74,9 +74,9 @@
                   & partial_relation_possible(action='add')
                   & partial_may_add_relation())
     registered = accepts_compat(Action.registered)
-    
+
     category = 'addrelated'
-                
+
     def url(self):
         current_entity = self.rset.get_entity(self.row or 0, self.col or 0)
         linkto = '%s:%s:%s' % (self.rtype, current_entity.eid, target(self))
@@ -91,4 +91,4 @@
     registered = deprecate(condition_compat(accepts_compat(Action.registered)),
                            msg='EntityAction is deprecated, use Action with '
                            'appropriate selectors')
-    
+
--- a/web/component.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/web/component.py	Wed Apr 22 18:44:30 2009 +0200
@@ -22,46 +22,46 @@
 class EntityVComponent(Component):
     """abstract base class for additinal components displayed in content
     headers and footer according to:
-    
+
     * the displayed entity's type
     * a context (currently 'header' or 'footer')
 
     it should be configured using .accepts, .etype, .rtype, .target and
     .context class attributes
     """
-    
+
     __registry__ = 'contentnavigation'
     __select__ = one_line_rset() & primary_view() & match_context_prop()
     registered = accepts_compat(has_relation_compat(condition_compat(View.registered)))
-    
+
     property_defs = {
         _('visible'):  dict(type='Boolean', default=True,
                             help=_('display the box or not')),
         _('order'):    dict(type='Int', default=99,
                             help=_('display order of the component')),
         _('context'):  dict(type='String', default='header',
-                            vocabulary=(_('navtop'), _('navbottom'), 
+                            vocabulary=(_('navtop'), _('navbottom'),
                                         _('navcontenttop'), _('navcontentbottom')),
                             #vocabulary=(_('header'), _('incontext'), _('footer')),
                             help=_('context where this component should be displayed')),
         _('htmlclass'):dict(type='String', default='mainRelated',
                             help=_('html class of the component')),
     }
-    
+
     context = 'navcontentbottom' # 'footer' | 'header' | 'incontext'
-    
+
     def call(self, view=None):
         return self.cell_call(0, 0, view)
 
     def cell_call(self, row, col, view=None):
         raise NotImplementedError()
 
-    
+
 class NavigationComponent(Component):
     """abstract base class for navigation components"""
     id = 'navigation'
     __select__ = paginated_rset()
-    
+
     page_size_property = 'navigation.page-size'
     start_param = '__start'
     stop_param = '__stop'
@@ -69,7 +69,7 @@
     selected_page_link_templ = u'<span class="selectedSlice"><a href="%s" title="%s">%s</a></span>'
     previous_page_link_templ = next_page_link_templ = page_link_templ
     no_previous_page_link = no_next_page_link = u''
-    
+
     def __init__(self, req, rset, **kwargs):
         super(NavigationComponent, self).__init__(req, rset, **kwargs)
         self.starting_from = 0
@@ -90,9 +90,9 @@
 
     def set_page_size(self, page_size):
         self._page_size = page_size
-        
+
     page_size = property(get_page_size, set_page_size)
-    
+
     def page_boundaries(self):
         try:
             stop = int(self.req.form[self.stop_param]) + 1
@@ -101,7 +101,7 @@
             start, stop = 0, self.page_size
         self.starting_from = start
         return start, stop
-        
+
     def clean_params(self, params):
         if self.start_param in params:
             del params[self.start_param]
@@ -141,13 +141,13 @@
 class RelatedObjectsVComponent(EntityVComponent):
     """a section to display some related entities"""
     __select__ = EntityVComponent.__select__ & partial_has_related_entities()
-    
+
     vid = 'list'
-    
+
     def rql(self):
         """override this method if you want to use a custom rql query"""
         return None
-    
+
     def cell_call(self, row, col, view=None):
         rql = self.rql()
         if rql is None:
--- a/web/controller.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/web/controller.py	Wed Apr 22 18:44:30 2009 +0200
@@ -47,7 +47,7 @@
         for subj in subjs.split('_'):
             for obj in objs.split('_'):
                 yield typed_eid(subj), rtype, typed_eid(obj)
-        
+
 def append_url_params(url, params):
     """append raw parameters to the url. Given parameters, if any, are expected
     to be already url-quoted.
@@ -75,7 +75,7 @@
         # attributes use to control after edition redirection
         self._after_deletion_path = None
         self._edited_entity = None
-        
+
     def publish(self, rset=None):
         """publish the current request, with an option input rql string
         (already processed if necessary)
@@ -94,7 +94,7 @@
             self.rset = pp.process_query(rql, self.req)
             return self.rset
         return None
-    
+
     def check_expected_params(self, params):
         """check that the given list of parameters are specified in the form
         dictionary
@@ -106,7 +106,7 @@
         if missing:
             raise RequestError('missing required parameter(s): %s'
                                % ','.join(missing))
-    
+
     def parse_datetime(self, value, etype='Datetime'):
         """get a datetime or time from a string (according to etype)
         Datetime formatted as Date are accepted
@@ -141,7 +141,7 @@
         #       relation) that might not be satisfied yet (in case of creations)
         if not self._edited_entity:
             self._edited_entity = entity
-        
+
     def delete_entities(self, eidtypes):
         """delete entities from the repository"""
         redirect_info = set()
@@ -160,7 +160,7 @@
             self.req.set_message(self.req._('entities deleted'))
         else:
             self.req.set_message(self.req._('entity deleted'))
-        
+
     def delete_relations(self, rdefs):
         """delete relations from the repository"""
         # FIXME convert to using the syntax subject:relation:eids
@@ -169,7 +169,7 @@
             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'))
-    
+
     def insert_relations(self, rdefs):
         """insert relations into the repository"""
         execute = self.req.execute
@@ -177,7 +177,7 @@
             rql = 'SET X %s Y where X eid %%(x)s, Y eid %%(y)s' % rtype
             execute(rql, {'x': subj, 'y': obj}, ('x', 'y'))
 
-    
+
     def reset(self):
         """reset form parameters and redirect to a view determinated by given
         parameters
@@ -221,7 +221,7 @@
         url = self.build_url(path, **newparams)
         url = append_url_params(url, self.req.form.get('__redirectparams'))
         raise Redirect(url)
-    
+
 
     def _return_to_edition_view(self, newparams):
         """apply-button case"""
--- a/web/facet.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/web/facet.py	Wed Apr 22 18:44:30 2009 +0200
@@ -339,7 +339,7 @@
     __select__ = partial_relation_possible() & match_context_prop()
     # class attributes to configure the rel ation facet
     rtype = None
-    role = 'subject' 
+    role = 'subject'
     target_attr = 'eid'
     # set this to a stored procedure name if you want to sort on the result of
     # this function's result instead of direct value
--- a/web/views/magicsearch.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/web/views/magicsearch.py	Wed Apr 22 18:44:30 2009 +0200
@@ -41,7 +41,7 @@
     :param translations: the reverted l10n dict
 
     :type schema: `cubicweb.schema.Schema`
-    :param schema: the application's schema    
+    :param schema: the application's schema
     """
     # var_types is used as a map : var_name / var_type
     vartypes = {}
@@ -107,7 +107,7 @@
         if rtype is None:
             continue
         relation.r_type = rtype
-    
+
 
 
 QUOTED_SRE = re.compile(r'(.*?)(["\'])(.+?)\2')
@@ -145,7 +145,7 @@
             return req.execute(*args)
         finally:
             # rollback necessary to avoid leaving the connection in a bad state
-            req.cnx.rollback() 
+            req.cnx.rollback()
 
     def preprocess_query(self, uquery, req):
         raise NotImplementedError()
@@ -161,10 +161,10 @@
     priority = 0
     def preprocess_query(self, uquery, req):
         return uquery,
-    
+
 
 class QueryTranslator(BaseQueryProcessor):
-    """ parses through rql and translates into schema language entity names 
+    """ parses through rql and translates into schema language entity names
     and attributes
     """
     priority = 2
@@ -185,7 +185,7 @@
     preprocessing query in shortcut form to their RQL form
     """
     priority = 4
-    
+
     def preprocess_query(self, uquery, req):
         """try to get rql from an unicode query string"""
         args = None
@@ -193,7 +193,7 @@
         try:
             # Process as if there was a quoted part
             args = self._quoted_words_query(uquery)
-        ## No quoted part  
+        ## No quoted part
         except BadRQLQuery:
             words = uquery.split()
             if len(words) == 1:
@@ -205,7 +205,7 @@
             else:
                 args = self._multiple_words_query(words)
         return args
-    
+
     def _get_entity_type(self, word):
         """check if the given word is matching an entity type, return it if
         it's the case or raise BadRQLQuery if not
@@ -214,7 +214,7 @@
         try:
             return trmap(self.config, self.vreg.schema, self.req.lang)[etype]
         except KeyError:
-            raise BadRQLQuery('%s is not a valid entity name' % etype)        
+            raise BadRQLQuery('%s is not a valid entity name' % etype)
 
     def _get_attribute_name(self, word, eschema):
         """check if the given word is matching an attribute of the given entity type,
@@ -261,7 +261,7 @@
         if var is None:
             var = etype[0]
         return '%s %s %s%%(text)s' % (var, searchattr, searchop)
-        
+
     def _two_words_query(self, word1, word2):
         """Specific process for two words query (case (2) of preprocess_rql)
         """
@@ -272,7 +272,7 @@
         # else, suppose it's a shortcut like : Person Smith
         rql = '%s %s WHERE %s' % (etype, etype[0], self._complete_rql(word2, etype))
         return rql, {'text': word2}
-           
+
     def _three_words_query(self, word1, word2, word3):
         """Specific process for three words query (case (3) of preprocess_rql)
         """
@@ -336,13 +336,13 @@
             return self._three_words_query(word1, word2, quoted_part)
             # return ori_rql
         raise BadRQLQuery("unable to handle request %r" % ori_rql)
-    
+
 
- 
+
 class FullTextTranslator(BaseQueryProcessor):
     priority = 10
     name = 'text'
-    
+
     def preprocess_query(self, uquery, req):
         """suppose it's a plain text query"""
         return 'Any X WHERE X has_text %(text)s', {'text': uquery}
--- a/web/views/urlrewrite.py	Wed Apr 22 18:42:58 2009 +0200
+++ b/web/views/urlrewrite.py	Wed Apr 22 18:44:30 2009 +0200
@@ -85,7 +85,7 @@
         (rgx('/doc/(.+?)/?'), dict(vid='wdoc', fid=r'\1')),
         (rgx('/changelog/?'), dict(vid='changelog')),
         ]
-    
+
     def rewrite(self, req, uri):
         """for each `input`, `output `in rules, if `uri` matches `input`,
         req's form is updated with `output`
@@ -179,7 +179,7 @@
     rules = [
         # rgxp : callback
         (rgx('/search/(.+)'), build_rset(rql=r'Any X WHERE X has_text %(text)s',
-                                         rgxgroups=[('text', 1)])), 
+                                         rgxgroups=[('text', 1)])),
         ]
 
     def rewrite(self, req, uri):