From: gmcm Date: Thu, 1 Aug 2002 15:06:26 +0000 (+0000) Subject: Use same regex to split search terms as used to index text. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=89591aaaaa98e0aa929cc1544bdc6b9348057f3c;p=roundup.git Use same regex to split search terms as used to index text. Fix to back_metakit for not changing journaltag on reopen. Fix htmltemplate's do_link so [No ] strings are href'd. Fix bogus "nosy edited ok" msg - the **d syntax does NOT share d between caller and callee. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@946 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 979382f..0de7702 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.57 2002-07-31 23:57:36 richard Exp $ +#$Id: back_anydbm.py,v 1.58 2002-08-01 15:06:24 gmcm Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -944,7 +944,7 @@ class Class(hyperdb.Class): to modify the "creation" or "activity" properties cause a KeyError. """ if not propvalues: - return + return propvalues if propvalues.has_key('creation') or propvalues.has_key('activity'): raise KeyError, '"creation" and "activity" are reserved' @@ -1124,7 +1124,7 @@ class Class(hyperdb.Class): # nothing to do? if not propvalues: - return + return propvalues # do the set, and journal it self.db.setnode(self.classname, nodeid, node) @@ -1135,6 +1135,8 @@ class Class(hyperdb.Class): self.fireReactors('set', nodeid, oldvalues) + return propvalues + def retire(self, nodeid): """Retire a node. @@ -1793,6 +1795,9 @@ class IssueClass(Class, roundupdb.IssueClass): # #$Log: not supported by cvs2svn $ +#Revision 1.57 2002/07/31 23:57:36 richard +# . web forms may now unset Link values (like assignedto) +# #Revision 1.56 2002/07/31 22:04:33 richard #cleanup # diff --git a/roundup/backends/back_metakit.py b/roundup/backends/back_metakit.py index 26bf2aa..d78b27f 100755 --- a/roundup/backends/back_metakit.py +++ b/roundup/backends/back_metakit.py @@ -12,6 +12,12 @@ def Database(config, journaltag=None): if db is None or db._db is None: db = _Database(config, journaltag) _dbs[config.DATABASE] = db + else: + db.journaltag = journaltag + try: + delattr(db, 'curuserid') + except AttributeError: + pass return db class _Database(hyperdb.Database): @@ -273,7 +279,7 @@ class Class: if not isnew: self.fireAuditors('set', nodeid, propvalues) if not propvalues: - return + return propvalues if propvalues.has_key('id'): raise KeyError, '"id" is reserved' if self.db.journaltag is None: @@ -328,6 +334,9 @@ class Class: if value is not None and not isinstance(value, type('')): raise ValueError, 'property "%s" link value be a string'%( propname) + # Roundup sets to "unselected" by passing None + if value is None: + value = 0 # if it isn't a number, it's a key try: int(value) @@ -408,6 +417,8 @@ class Class: for id in adds: sv.append(fid=int(id)) changes[key] = oldvalue + if not rmvd and not adds: + del propvalues[key] elif isinstance(prop, hyperdb.String): @@ -456,7 +467,7 @@ class Class: # nothing to do? if not propvalues: - return + return propvalues if not propvalues.has_key('activity'): row.activity = int(time.time()) if isnew: @@ -474,6 +485,8 @@ class Class: self.db.addjournal(self.classname, nodeid, _SET, changes) self.fireReactors('set', nodeid, oldnode) + return propvalues + def retire(self, nodeid): self.fireAuditors('retire', nodeid, None) view = self.getview(1) diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index 94aa962..5407557 100644 --- a/roundup/cgi_client.py +++ b/roundup/cgi_client.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: cgi_client.py,v 1.155 2002-08-01 00:56:22 richard Exp $ +# $Id: cgi_client.py,v 1.156 2002-08-01 15:06:06 gmcm Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -717,7 +717,7 @@ function help_window(helpurl, width, height) { else: props = parsePropsFromForm(self.db, cl, self.form, self.nodeid) # make changes to the node - self._changenode(props) + props = self._changenode(props) # handle linked nodes self._post_editnode(self.nodeid) # and some nice feedback for the user @@ -814,7 +814,7 @@ function help_window(helpurl, width, height) { props['files'] = cl.get(self.nodeid, 'files') + files # make the changes - cl.set(self.nodeid, **props) + return cl.set(self.nodeid, **props) def _createnode(self): ''' create a node based on the contents of the form @@ -1703,6 +1703,12 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): # # $Log: not supported by cvs2svn $ +# Revision 1.155 2002/08/01 00:56:22 richard +# Added the web access and email access permissions, so people can restrict +# access to users who register through the email interface (for example). +# Also added "security" command to the roundup-admin interface to display the +# Role/Permission config for an instance. +# # Revision 1.154 2002/07/31 23:57:36 richard # . web forms may now unset Link values (like assignedto) # diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 4fd620b..2721cbb 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.108 2002-07-31 22:40:50 gmcm Exp $ +# $Id: htmltemplate.py,v 1.109 2002-08-01 15:06:08 gmcm Exp $ __doc__ = """ Template engine. @@ -403,13 +403,13 @@ class TemplateFunctions: # get the value value = self.determine_value(property) - if value in ('', None, []): - return _('[no %(propname)s]')%{'propname':property.capitalize()} propclass = self.properties[property] if isinstance(propclass, hyperdb.Boolean): value = value and "Yes" or "No" elif isinstance(propclass, hyperdb.Link): + if value in ('', None, []): + return _('[no %(propname)s]')%{'propname':property.capitalize()} linkname = propclass.classname linkcl = self.db.classes[linkname] k = linkcl.labelprop(1) @@ -427,6 +427,8 @@ class TemplateFunctions: else: return '%s'%(linkname, value, title, label) elif isinstance(propclass, hyperdb.Multilink): + if value in ('', None, []): + return _('[no %(propname)s]')%{'propname':property.capitalize()} linkname = propclass.classname linkcl = self.db.classes[linkname] k = linkcl.labelprop(1) @@ -448,9 +450,13 @@ class TemplateFunctions: title, label)) return ', '.join(l) if is_download: + if value in ('', None, []): + return _('[no %(propname)s]')%{'propname':property.capitalize()} return '%s'%(self.classname, self.nodeid, value, value) else: + if value in ('', None, []): + value = _('[no %(propname)s]')%{'propname':property.capitalize()} return '%s'%(self.classname, self.nodeid, value) def do_count(self, property, **args): @@ -929,6 +935,7 @@ class IndexTemplate(TemplateFunctions): def clear(self): self.db = self.cl = self.properties = None + del self.globals['handle_require'] TemplateFunctions.clear(self) def buildurl(self, filterspec, search_text, filter, columns, sort, group, pagesize): @@ -1019,7 +1026,8 @@ class IndexTemplate(TemplateFunctions): if nodeids is None: if search_text != '': matches = self.db.indexer.search( - search_text.split(' '), self.cl) + re.findall(r'\b\w{2,25}\b', search_text), self.cl) + #search_text.split(' '), self.cl) nodeids = self.cl.filter(matches, filterspec, sort, group) for nodeid in nodeids[startwith:startwith+pagesize]: # check for a group heading @@ -1351,6 +1359,7 @@ class ItemTemplate(TemplateFunctions): def clear(self): self.db = self.cl = self.properties = None + del self.globals['handle_require'] TemplateFunctions.clear(self) def render(self, nodeid): @@ -1441,6 +1450,10 @@ class NewItemTemplate(ItemTemplate): # # $Log: not supported by cvs2svn $ +# Revision 1.108 2002/07/31 22:40:50 gmcm +# Fixes to the search form and saving queries. +# Fixes to sorting in back_metakit.py. +# # Revision 1.107 2002/07/30 05:27:30 richard # nicer error messages, and a bugfix #