[Zope-Checkins] CVS: Zope2 - util.py:1.1.2.2
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Tue, 22 May 2001 10:04:50 -0400
Update of /cvs-repository/Zope2/lib/python/Products/PluginIndexes/common
In directory serenade:/tmp/cvs-serv18747/common
Modified Files:
Tag: ajung-dropin-registry
util.py
Log Message:
--- Updated File util.py in package Zope2 --
--- util.py 2001/05/22 13:19:21 1.1.2.1
+++ util.py 2001/05/22 14:04:50 1.1.2.2
@@ -115,14 +115,18 @@
keys = request[iid]
- if type(keys)==StringType:
- """ single query """
- self.keys = [keys]
-
- elif type(keys)==ListType:
- """ list of queries """
- self.keys = keys
+ if type(keys) in [StringType,ListType]:
+ if type(keys) == StringType:
+ self.keys = [keys.strip()]
+ else:
+ self.keys = keys
+
+ params = filter(lambda x,id=self.id: x.startswith(id+'_') , request.keys())
+ params = map(lambda x,id=self.id: x[len(id)+1:],params)
+ for p in params:
+ setattr(self,p,request[self.id+'_'+p])
+
else:
""" query is of type record """
record = keys
@@ -134,7 +138,7 @@
if type(keys)== StringType:
- self.keys = [keys]
+ self.keys = [keys.strip()]
elif type(keys) == ListType:
self.keys = keys
@@ -143,5 +147,11 @@
setattr(self,k,getattr(record,k))
- print dir(record)
-
+ def get(self,k,default_v):
+
+ if hasattr(self,k):
+ v = getattr(self,k)
+ if v: return v
+ else: return default_v
+ else:
+ return default_v