[Zope-Checkins] CVS: Zope/lib/python/Shared/DC/ZRDB - Aqueduct.py:1.56 Connection.py:1.35 DA.py:1.105 RDB.py:1.33 Results.py:1.14 Search.py:1.20 THUNK.py:1.6 TM.py:1.10 __init__.py:1.5 dbi_db.py:1.10 sqlgroup.py:1.9 sqltest.py:1.18 sqlvar.py:1.13
Martijn Pieters
mj@zope.com
Wed, 14 Aug 2002 17:51:31 -0400
Update of /cvs-repository/Zope/lib/python/Shared/DC/ZRDB
In directory cvs.zope.org:/tmp/cvs-serv16745/DC/ZRDB
Modified Files:
Aqueduct.py Connection.py DA.py RDB.py Results.py Search.py
THUNK.py TM.py __init__.py dbi_db.py sqlgroup.py sqltest.py
sqlvar.py
Log Message:
Clean up indentation and trailing whitespace.
=== Zope/lib/python/Shared/DC/ZRDB/Aqueduct.py 1.55 => 1.56 ===
--- Zope/lib/python/Shared/DC/ZRDB/Aqueduct.py:1.55 Fri Feb 15 11:30:29 2002
+++ Zope/lib/python/Shared/DC/ZRDB/Aqueduct.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__doc__='''Shared classes and functions
@@ -73,12 +73,12 @@
try:
if not arg['optional']: missing.append(name)
except: missing.append(name)
-
+
# Note: the code above tries to check if an argument of the
# ZSQL method above has the "optional" flag set (in case the
# argument is omitted from the ZSQL function call). But there
- # is neither corresponding code inside the parse() function to
- # check for the "optional" parameter nor any documentation.
+ # is neither corresponding code inside the parse() function to
+ # check for the "optional" parameter nor any documentation.
# So we omit the check for the optional parameter. There will
# be probably no code break but there will be hopefully more code
# to work as supposed to work.
@@ -114,7 +114,7 @@
def manage_test(self, REQUEST):
'Perform an actual query'
-
+
result=self(REQUEST)
report=HTML(custom_default_report(self.id, result))
return apply(report,(self,REQUEST),{self.id:result})
@@ -123,7 +123,7 @@
" "
raise 'Redirect', ("%s/manage_testForm" % URL1)
-class Composite:
+class Composite:
def _getquery(self,id):
@@ -141,7 +141,7 @@
if i > 100: raise AttributeError, id
i=i+1
o=o.aq_parent
-
+
def myQueryIds(self):
return map(
lambda k, queries=self.queries:
@@ -291,10 +291,10 @@
output.write(s)
def decodestring(s):
- f = StringIO(s)
- g = StringIO()
- decode(f, g)
- return g.getvalue()
+ f = StringIO(s)
+ g = StringIO()
+ decode(f, g)
+ return g.getvalue()
class Args:
def __init__(self, data, keys):
@@ -400,7 +400,7 @@
):
- mo = header_re.match(html)
+ mo = header_re.match(html)
if mo is None: return html
headers, html = mo.group(1,3)
=== Zope/lib/python/Shared/DC/ZRDB/Connection.py 1.34 => 1.35 ===
--- Zope/lib/python/Shared/DC/ZRDB/Connection.py:1.34 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/Connection.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__doc__='''Generic Database Connection Support
@@ -30,7 +30,7 @@
AccessControl.Role.RoleManager,
OFS.SimpleItem.Item,
Acquisition.Implicit,
- ):
+ ):
# Specify definitions for tabs:
manage_options=(
@@ -42,7 +42,7 @@
+AccessControl.Role.RoleManager.manage_options
+OFS.SimpleItem.Item.manage_options
)
-
+
# Specify how individual operations add up to "permissions":
__ac_permissions__=(
('View management screens', ('manage_main',)),
@@ -69,7 +69,7 @@
s=Connection.inheritedAttribute('title_and_id')(self)
if hasattr(self, '_v_connected') and self._v_connected:
s="%s, which is connected" % s
- else:
+ else:
s="%s, which is <font color=red> not connected</font>" % s
return s
@@ -77,7 +77,7 @@
s=Connection.inheritedAttribute('title_or_id')(self)
if hasattr(self, '_v_connected') and self._v_connected:
s="%s (connected)" % s
- else:
+ else:
s="%s (<font color=red> not connected</font>)" % s
return s
@@ -87,7 +87,7 @@
self.title=title
self.connection_string=connection_string
if check: self.connect(connection_string)
-
+
manage_properties=DTMLFile('dtml/connectionEdit', globals())
def manage_edit(self, title, connection_string, check=None, REQUEST=None):
"""Change connection
@@ -116,7 +116,7 @@
if REQUEST is None:
return result #return unadulterated result objects
-
+
if result._searchable_result_columns():
r=custom_default_report(self.id, result)
else:
@@ -132,7 +132,7 @@
report=apply(report,(self,REQUEST),{self.id:result})
return report
-
+
manage_main=DTMLFile('dtml/connectionStatus', globals())
=== Zope/lib/python/Shared/DC/ZRDB/DA.py 1.104 => 1.105 ===
--- Zope/lib/python/Shared/DC/ZRDB/DA.py:1.104 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/DA.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__doc__='''Generic Database adapter'''
@@ -74,7 +74,7 @@
_zclass=None
allow_simple_one_argument_traversal=None
template_class=SQL
-
+
manage_options=(
(
{'label':'Edit', 'action':'manage_main',
@@ -87,7 +87,7 @@
+AccessControl.Role.RoleManager.manage_options
+OFS.SimpleItem.Item.manage_options
)
-
+
# Specify how individual operations add up to "permissions":
__ac_permissions__=(
('View management screens',
@@ -100,12 +100,12 @@
'manage_product_zclass_info', 'PUT')),
('Use Database Methods', ('__call__',''), ('Anonymous','Manager')),
)
-
+
def __init__(self, id, title, connection_id, arguments, template):
self.id=str(id)
self.manage_edit(title, connection_id, arguments, template)
-
+
manage_advancedForm=DTMLFile('dtml/advanced', globals())
test_url___roles__=None
@@ -125,7 +125,7 @@
def _er(self,title,connection_id,arguments,template,
SUBMIT,sql_pref__cols,sql_pref__rows,REQUEST):
dr,dc = self._size_changes[SUBMIT]
-
+
rows=max(1,atoi(sql_pref__rows)+dr)
cols=max(40,atoi(sql_pref__cols)+dc)
e=(DateTime('GMT') + 365).rfc822()
@@ -162,7 +162,7 @@
if self.wl_isLocked():
raise ResourceLockedError, 'SQL Method is locked via WebDAV'
-
+
self.title=str(title)
self.connection_id=str(connection_id)
arguments=str(arguments)
@@ -211,7 +211,7 @@
'lib/python/Products/ACMEWidgets/Extensions/foo.py'. If this
failes, then the file 'Extensions/ACMEWidgets.foo.py' will be
used.
-
+
"""
# paranoid type checking
if type(max_rows) is not type(1):
@@ -219,10 +219,10 @@
if type(max_cache) is not type(1):
max_cache=atoi(max_cache)
if type(cache_time) is not type(1):
- cache_time=atoi(cache_time)
+ cache_time=atoi(cache_time)
class_name=str(class_name)
class_file=str(class_file)
-
+
self.max_rows_ = max_rows
self.max_cache_, self.cache_time_ = max_cache, cache_time
self._v_cache={}, Bucket()
@@ -236,7 +236,7 @@
self._zclass=d['meta_class']
break
-
+
if REQUEST is not None:
m="ZSQL Method advanced settings have been set"
return self.manage_advancedForm(self,REQUEST,manage_tabs_message=m)
@@ -329,7 +329,7 @@
None, REQUEST, t, v, tb, None, report)
return report
-
+
finally: tb=None
def index_html(self, REQUEST):
@@ -359,7 +359,7 @@
if int(cache[q][0]) == key:
del cache[q]
del keys[-1]
-
+
if cache.has_key(query):
k, r = cache[query]
if k > t: return r
@@ -398,7 +398,7 @@
try: DB__=dbc()
except: raise 'Database Error', (
'%s is not connected to a database' % self.id)
-
+
if hasattr(self, 'aq_parent'):
p=self.aq_parent
if self._isBeingAccessedAsZClassDefinedInstanceMethod():
@@ -455,7 +455,7 @@
r=results[0]
# if hasattr(self, 'aq_parent'): r=r.__of__(self.aq_parent)
return r
-
+
self._arg[key] # raise KeyError if not an arg
return Traverse(self,{},key)
@@ -481,8 +481,8 @@
x['selected'] = (z is Z) and 'selected' or ''
del x['meta_class']
r.append(x)
-
- return r
+
+ return r
@@ -515,7 +515,7 @@
args[name]=key
- if len(args) < len(da._arg):
+ if len(args) < len(da._arg):
return self.__class__(da, args)
key=self # "consume" key
@@ -547,4 +547,3 @@
r=self.__dict__['_r']
if hasattr(r, name): return getattr(r,name)
return getattr(self.__dict__['_da'], name)
-
=== Zope/lib/python/Shared/DC/ZRDB/RDB.py 1.32 => 1.33 ===
--- Zope/lib/python/Shared/DC/ZRDB/RDB.py:1.32 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/RDB.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__doc__='''Class for reading RDB files
@@ -43,7 +43,7 @@
class SQLAlias(ExtensionClass.Base):
def __init__(self, name): self._n=name
def __of__(self, parent): return getattr(parent, self._n)
-
+
class NoBrains: pass
class DatabaseResults:
@@ -63,7 +63,7 @@
self._parent=parent
if zbrains is None: zbrains=NoBrains
-
+
while line and line.find('#') != -1 : line=readline()
line=line[:-1]
@@ -91,14 +91,14 @@
line=readline()
line=line[:-1]
if line[-1:] in '\r\n': line=line[:-1]
-
+
self._defs=defs=split(line,'\t')
if not defs: raise ValueError, 'No column definitions'
if len(defs) != nv:
raise ValueError, (
"""The number of column names and the number of column
definitions are different.""")
-
+
i=0
self._parsers=parsers=[]
defre=re.compile(r'([0-9]*)([a-zA-Z])?')
@@ -126,7 +126,7 @@
d={'name': name, 'type': type, 'width': width, 'parser': parser}
items.append(d)
dd[name]=d
-
+
parsers.append((i,parser))
i=i+1
@@ -134,7 +134,7 @@
names=tuple(names)
class r(Record, Implicit, brains, zbrains):
- 'Result record class'
+ 'Result record class'
r.__record_schema__=schema
for k in filter(lambda k: k[:2]=='__', Record.__dict__.keys()):
@@ -153,7 +153,7 @@
binit(self.__of__(parent))
r.__dict__['__init__']=__init__
-
+
self._class=r
@@ -191,7 +191,7 @@
raise ValueError, (
"""The number of items in record %s is invalid
<pre>%s\n%s\n%s\n%s</pre>
- """
+ """
% (index, ('='*40), line, ('='*40), fields))
for i, parser in self._parsers:
try: v=parser(fields[i])
=== Zope/lib/python/Shared/DC/ZRDB/Results.py 1.13 => 1.14 ===
--- Zope/lib/python/Shared/DC/ZRDB/Results.py:1.13 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/Results.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
import ExtensionClass
import string
@@ -19,7 +19,7 @@
class SQLAlias(ExtensionClass.Base):
def __init__(self, name): self._n=name
def __of__(self, parent): return getattr(parent, self._n)
-
+
class NoBrains: pass
class Results:
@@ -60,12 +60,12 @@
i=i+1
self._nv=nv=len(names)
-
+
# Create a record class to hold the records.
names=tuple(names)
class r(Record, Implicit, brains, zbrains):
- 'Result record class'
+ 'Result record class'
r.__record_schema__=schema
for k in Record.__dict__.keys():
@@ -86,7 +86,7 @@
binit(self)
r.__dict__['__init__']=__init__
-
+
self._class=r
# OK, we've read meta data, now get line indexes
@@ -137,7 +137,7 @@
else: nstrings.append(i)
if item.has_key('width'): append('%s%s' % (item['width'], t))
else: r.append(t)
-
+
r=[join(self._names, '\t'), join(r,'\t')]
append=r.append
@@ -157,5 +157,5 @@
row[i]=tostr(d[i])
append(join(row,'\t'))
append('')
-
+
return join(r,'\n')
=== Zope/lib/python/Shared/DC/ZRDB/Search.py 1.19 => 1.20 ===
--- Zope/lib/python/Shared/DC/ZRDB/Search.py:1.19 Fri Jul 19 14:24:23 2002
+++ Zope/lib/python/Shared/DC/ZRDB/Search.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__doc__='''Search Interface Wizard
@@ -39,14 +39,14 @@
arguments={}
keys=[]
- checkPermission=getSecurityManager().checkPermission
+ checkPermission=getSecurityManager().checkPermission
for q in qs:
url=q.absolute_url()
if input_id:
for name, arg in q._searchable_arguments().items():
if len(qs) > 1: key="%s/%s" % (id,name)
- else: key=name
+ else: key=name
arguments[key]=arg
keys.append(key)
if q._searchable_result_columns() is None:
@@ -75,7 +75,7 @@
self.manage_addDocument(
report_id,report_title,
('<dtml-var standard_html_header>\n%s\n'
- '<dtml-var standard_html_footer>' %
+ '<dtml-var standard_html_footer>' %
join(map(lambda q, report_style=report_style:
custom_default_report(q.id, q, no_table=report_style), qs),
'\n<hr>\n')))
@@ -99,13 +99,13 @@
self.manage_addProduct['PageTemplates'].manage_addPageTemplate(
report_id,report_title,
('<html><body>\n%s\n'
- '</body></html>' %
+ '</body></html>' %
join(map(lambda q, report_style=report_style:
custom_default_zpt_report(q.id, q, no_table=report_style), qs),
'\n<hr>\n')))
if REQUEST: return self.manage_main(self,REQUEST)
-
+
def ZQueryIds(self):
# Note that report server configurations will expend on this
@@ -133,26 +133,26 @@
# Now extend search to parent
try: o=o.aq_parent
except: return t
-
+
if n > 100: return t # Seat belt
n=n+1
def _getquery(self,id):
- o=self
- i=0
- while 1:
- __traceback_info__=o
- q=getattr(o,id)
- try:
- if hasattr(q,'_searchable_arguments'):
- try: q=q.__of__(self.aq_parent)
- except: pass
- return q
- except: pass
- if i > 100: raise AttributeError, id
- i=i+1
- o=o.aq_parent
+ o=self
+ i=0
+ while 1:
+ __traceback_info__=o
+ q=getattr(o,id)
+ try:
+ if hasattr(q,'_searchable_arguments'):
+ try: q=q.__of__(self.aq_parent)
+ except: pass
+ return q
+ except: pass
+ if i > 100: raise AttributeError, id
+ i=i+1
+ o=o.aq_parent
def default_input_form(arguments,action='query',
@@ -252,14 +252,3 @@
'</body></html>\n'
% (tabs, action)
)
-
-
-
-
-
-
-
-
-
-
-
=== Zope/lib/python/Shared/DC/ZRDB/THUNK.py 1.5 => 1.6 ===
--- Zope/lib/python/Shared/DC/ZRDB/THUNK.py:1.5 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/THUNK.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
import TM, ThreadLock
@@ -18,7 +18,7 @@
class THUNKED_TM(TM.TM):
"""A big heavy hammer for handling non-thread safe DAs
"""
-
+
def _register(self):
if not self._registered:
thunk_lock.acquire()
@@ -30,7 +30,7 @@
raise
else:
self._registered=1
-
+
def tpc_finish(self, *ignored):
if self._registered:
try: self._finish()
=== Zope/lib/python/Shared/DC/ZRDB/TM.py 1.9 => 1.10 ===
--- Zope/lib/python/Shared/DC/ZRDB/TM.py:1.9 Mon Mar 11 17:05:13 2002
+++ Zope/lib/python/Shared/DC/ZRDB/TM.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
"""Provide support for linking an external transaction manager with Zope's
"""
@@ -26,7 +26,7 @@
"""
_registered=None
-
+
def _begin(self): pass
def _register(self):
@@ -52,7 +52,7 @@
def tpc_finish(self, *ignored):
- if self._finalize:
+ if self._finalize:
try: self._finish()
finally: self._registered=0
=== Zope/lib/python/Shared/DC/ZRDB/__init__.py 1.4 => 1.5 ===
--- Zope/lib/python/Shared/DC/ZRDB/__init__.py:1.4 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/__init__.py Wed Aug 14 17:50:59 2002
@@ -1,12 +1,12 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
=== Zope/lib/python/Shared/DC/ZRDB/dbi_db.py 1.9 => 1.10 ===
--- Zope/lib/python/Shared/DC/ZRDB/dbi_db.py:1.9 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/dbi_db.py Wed Aug 14 17:50:59 2002
@@ -1,25 +1,25 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__doc__='''short description
$Id$'''
-# Copyright
+# Copyright
#
# Copyright 1997 Digital Creations, Inc, 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
-# rights reserved.
-#
+# rights reserved.
+#
__version__='$Revision$'[11:-2]
import string, sys
@@ -51,7 +51,7 @@
self.connection=connection
db=self.db=self.Database_Connection(connection)
self.cursor=db.cursor()
-
+
def str(self,v, StringType=type('')):
if v is None: return ''
r=str(v)
@@ -70,7 +70,7 @@
if self._registered: return
get_transaction().register(self)
self._registered=1
-
+
def query(self,query_string, max_rows=9999999):
global failures, calls
@@ -126,7 +126,7 @@
desc=c.description
else:
raise sys.exc_info()
-
+
if result:
result=join(
map(
=== Zope/lib/python/Shared/DC/ZRDB/sqlgroup.py 1.8 => 1.9 ===
--- Zope/lib/python/Shared/DC/ZRDB/sqlgroup.py:1.8 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/sqlgroup.py Wed Aug 14 17:50:59 2002
@@ -1,24 +1,24 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
'''Inserting optional tests with 'sqlgroup'
-
+
It is sometimes useful to make inputs to an SQL statement
optinal. Doing so can be difficult, because not only must the
test be inserted conditionally, but SQL boolean operators may or
may not need to be inserted depending on whether other, possibly
optional, comparisons have been done. The 'sqlgroup' tag
- automates the conditional insertion of boolean operators.
+ automates the conditional insertion of boolean operators.
The 'sqlgroup' tag is a block tag. It can
have any number of 'and' and 'or' continuation tags.
@@ -26,7 +26,7 @@
The 'sqlgroup' tag has an optional attribure, 'required' to
specify groups that must include at least one test. This is
useful when you want to make sure that a query is qualified, but
- want to be very flexible about how it is qualified.
+ want to be very flexible about how it is qualified.
Suppose we want to find people with a given first or nick name,
city or minimum and maximum age. Suppose we want all inputs to be
@@ -62,13 +62,13 @@
'''
############################################################################
-# Copyright
+# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
-############################################################################
+############################################################################
__rcs_id__='$Id$'
__version__='$Revision$'[11:-2]
@@ -102,7 +102,7 @@
if s:
if r: r.append(tname)
r.append("%s\n" % s)
-
+
if r:
if len(r) > 1: r="(%s)\n" % join(r,' ')
else: r=r[0]
=== Zope/lib/python/Shared/DC/ZRDB/sqltest.py 1.17 => 1.18 ===
--- Zope/lib/python/Shared/DC/ZRDB/sqltest.py:1.17 Fri Aug 9 13:58:33 2002
+++ Zope/lib/python/Shared/DC/ZRDB/sqltest.py Wed Aug 14 17:50:59 2002
@@ -1,23 +1,23 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
'''Inserting optional tests with 'sqlgroup'
-
+
It is sometimes useful to make inputs to an SQL statement
optinal. Doing so can be difficult, because not only must the
test be inserted conditionally, but SQL boolean operators may or
may not need to be inserted depending on whether other, possibly
optional, comparisons have been done. The 'sqlgroup' tag
- automates the conditional insertion of boolean operators.
+ automates the conditional insertion of boolean operators.
The 'sqlgroup' tag is a block tag that has no attributes. It can
have any number of 'and' and 'or' continuation tags.
@@ -58,13 +58,13 @@
__rcs_id__='$Id$'
############################################################################
-# Copyright
+# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
-############################################################################
+############################################################################
__version__='$Revision$'[11:-2]
import sys
@@ -74,7 +74,7 @@
from string import find, split, join, atoi, atof
from types import ListType, TupleType, StringType
-class SQLTest:
+class SQLTest:
name='sqltest'
optional=multiple=None
@@ -83,14 +83,14 @@
multiple=1, optional=1, op=None)
name,expr = name_param(args,'sqlvar',1)
- if expr is None:
- expr=name
- else: expr=expr.eval
- self.__name__, self.expr = name, expr
+ if expr is None:
+ expr=name
+ else: expr=expr.eval
+ self.__name__, self.expr = name, expr
self.args=args
if not args.has_key('type'):
- raise ParseError, ('the type attribute is required', 'sqltest')
+ raise ParseError, ('the type attribute is required', 'sqltest')
self.type=t=args['type']
if not valid_type(t):
@@ -103,9 +103,9 @@
elif self.__name__ is None:
err = ' the column attribute is required if an expression is used'
raise ParseError, (err, 'sqltest')
- else:
+ else:
self.column=self.__name__
-
+
# Deal with optional operator specification
op = '=' # Default
if args.has_key('op'):
@@ -116,37 +116,37 @@
def render(self, md):
- name=self.__name__
-
+ name=self.__name__
+
t=self.type
args=self.args
try:
- expr=self.expr
- if type(expr) is type(''):
- v=md[expr]
- else:
- v=expr(md)
- except KeyError:
- if args.has_key('optional') and args['optional']:
- return ''
+ expr=self.expr
+ if type(expr) is type(''):
+ v=md[expr]
+ else:
+ v=expr(md)
+ except KeyError:
+ if args.has_key('optional') and args['optional']:
+ return ''
raise 'Missing Input', 'Missing input variable, <em>%s</em>' % name
-
+
if type(v) in (ListType, TupleType):
if len(v) > 1 and not self.multiple:
raise 'Multiple Values', (
'multiple values are not allowed for <em>%s</em>'
% name)
else: v=[v]
-
+
vs=[]
for v in v:
if not v and type(v) is StringType and t != 'string': continue
if t=='int':
try:
if type(v) is StringType:
- if v[-1:]=='L':
- v=v[:-1]
- atoi(v)
+ if v[-1:]=='L':
+ v=v[:-1]
+ atoi(v)
else: v=str(int(v))
except ValueError:
raise ValueError, (
@@ -166,10 +166,10 @@
#v="'%s'" % v
vs.append(v)
- if not vs and t=='nb':
- if args.has_key('optional') and args['optional']:
- return ''
- else:
+ if not vs and t=='nb':
+ if args.has_key('optional') and args['optional']:
+ return ''
+ else:
err = 'Invalid empty string value for <em>%s</em>' % name
raise ValueError, err
=== Zope/lib/python/Shared/DC/ZRDB/sqlvar.py 1.12 => 1.13 ===
--- Zope/lib/python/Shared/DC/ZRDB/sqlvar.py:1.12 Wed Nov 28 10:51:13 2001
+++ Zope/lib/python/Shared/DC/ZRDB/sqlvar.py Wed Aug 14 17:50:59 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
'''Inserting values with the 'sqlvar' tag
@@ -37,7 +37,7 @@
<dtml-sqlvar x type=nb optional>
if the value of 'x' is::
-
+
Let\'s do it
then the text inserted is:
@@ -50,13 +50,13 @@
__rcs_id__='$Id$'
############################################################################
-# Copyright
+# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
-############################################################################
+############################################################################
__version__='$Revision$'[11:-2]
from DocumentTemplate.DT_Util import ParseError, parse_params, name_param
@@ -65,7 +65,7 @@
str=__builtins__['str']
-class SQLVar:
+class SQLVar:
name='sqlvar'
def __init__(self, args):
@@ -130,7 +130,7 @@
else:
raise ValueError, (
'Invalid empty string value for <em>%s</em>' % name)
-
+
v=md.getitem('sql_quote__',0)(v)
#if find(v,"\'") >= 0: v=join(split(v,"\'"),"''")
#v="'%s'" % v