[Zope-Checkins] CVS: Products/DCOracle2 - CHANGELOG:1.53 SP.py:1.9
Matthew T. Kromer
matt@zope.com
Mon, 13 May 2002 12:56:32 -0400
Update of /cvs-repository/Products/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv17503
Modified Files:
CHANGELOG SP.py
Log Message:
Add patch from Collector #47, default args to stored procedures
=== Products/DCOracle2/CHANGELOG 1.52 => 1.53 ===
procedure will use NULL always e.g. proc(None) vs
proc(name=None) where name has a default. Collector # 48
+ o Change Z Oracle Stored Procedures so that arguments to
+ stored procedures can be acquired automatically from
+ REQUEST, or REQUEST and the context. The acquiring argument
+ mode is manageable via the Edit tab on the procedure. The
+ default mode is "Never" which is the old behavior, and requires
+ arguments to be explicitly passed. Collector # 47
Desired Features Not Yet Implemented:
=== Products/DCOracle2/SP.py 1.8 => 1.9 ===
info=None
- def __init__(self, id, title, connection, procname, check):
+ def __init__(self, id, title, connection, procname, acquire, check):
self.id = id
self.title = title
self.connection = connection
self.procname = procname
+ self.acquire = acquire
self._v_proc = None
self._v_db = None
@@ -146,13 +147,48 @@
if getattr(self,"_v_proc",None) is None: self._connect()
return self._v_proc.__doc__
+ def ZSPAcquireType(self):
+ aq = getattr(self,"acquire","never")
+ if aq not in ("never", "request", "always"): aq = 'never'
+
+ return aq
+
def __call__(self, *args, **kw):
if not getSecurityManager().checkPermission(
'Execute %s Stored Procedures' % dbstring, self):
# Ugh raising a string error
raise 'Unauthorized', "You are not authorized to access this resource"
- self._register()
+
if getattr(self,"_v_proc",None) is None: self._connect()
+
+ aq = self.ZSPAcquireType()
+
+ if aq != 'never':
+ REQUEST = getattr(self,'REQUEST',None)
+ else:
+ REQUEST = None
+
+ if REQUEST is not None:
+ # Our own version of the magic apply; take arguments out of REQUEST
+ argc = 0
+ argl = len(args)
+ _notfound = []
+ arglist = self._v_proc.argList()
+ for (name, type, mode) in arglist:
+ if 'IN' in mode:
+ argc = argc + 1
+ try:
+ v = REQUEST.get(name, _notfound)
+ except AttributeError:
+ v = _notfound
+ if v is _notfound and aq == 'always':
+ v = getattr(self, name, _notfound)
+ # Take an arg if it isn't in the positional or kw list
+ if (argl < argc and v is not _notfound and
+ not kw.has_key(name)):
+ kw[name] = v # Auto-import as kw arg
+
+ self._register()
try:
# Note, this does not do result promotion like the DA query will
# which is probably bad. OracleDates in particular look like
@@ -173,11 +209,12 @@
return ins
def manage_editZOracleStoredProcedure(self, title, connection, procname,
- URL1, RESPONSE=None):
+ acquire, URL1, RESPONSE=None):
"""Edit the stored procedure"""
self.title = title
self.connection = connection
self.procname = procname
+ self.acquire = acquire
self._v_proc = None
RESPONSE.redirect(URL1 + "/manage_procview?manage_tabs_message=Stored%20Procedure%20Changed")