Update of /cvsroot/pywin32/pywin32/pyisapi/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9434
Modified Files:
PyExtensionObjects.cpp PyFilterObjects.cpp
Log Message:
Allow GetServerVariable() to have a default specified, which will be used
instead of raising an exception.
Index: PyExtensionObjects.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/pyisapi/src/PyExtensionObjects.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PyExtensionObjects.cpp 9 Sep 2004 06:09:11 -0000 1.4
--- PyExtensionObjects.cpp 3 Oct 2004 07:23:25 -0000 1.5
***************
*** 326,333 ****
BOOL bRes = FALSE;
TCHAR * variable = NULL;
PyECB * pecb = (PyECB *) self;
// @pyparm string|variable||
! if (!PyArg_ParseTuple(args, "s:GetServerVariable", &variable))
return NULL;
--- 326,336 ----
BOOL bRes = FALSE;
TCHAR * variable = NULL;
+ PyObject *def = NULL;
PyECB * pecb = (PyECB *) self;
// @pyparm string|variable||
! // @pyparm object|default||If specified, the function will return this
! // value instead of raising an error if the variable could not be fetched.
! if (!PyArg_ParseTuple(args, "s|O:GetServerVariable", &variable, &def))
return NULL;
***************
*** 339,344 ****
bRes = pecb->m_pcb->GetServerVariable(variable, buf, &bufsize);
Py_END_ALLOW_THREADS
! if (!bRes)
return SetPyECBError("GetServerVariable");
}
return PyString_FromStringAndSize(buf, bufsize);
--- 342,352 ----
bRes = pecb->m_pcb->GetServerVariable(variable, buf, &bufsize);
Py_END_ALLOW_THREADS
! if (!bRes) {
! if (def) {
! Py_INCREF(def);
! return def;
! }
return SetPyECBError("GetServerVariable");
+ }
}
return PyString_FromStringAndSize(buf, bufsize);
Index: PyFilterObjects.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/pyisapi/src/PyFilterObjects.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PyFilterObjects.cpp 9 Sep 2004 00:22:28 -0000 1.3
--- PyFilterObjects.cpp 3 Oct 2004 07:23:25 -0000 1.4
***************
*** 199,207 ****
BOOL bRes = FALSE;
TCHAR * variable = NULL;
PyHFC * phfc = (PyHFC *) self;
// @pyparm string|variable||
! if (!PyArg_ParseTuple(args, "s:GetServerVariable", &variable))
return NULL;
--- 199,210 ----
BOOL bRes = FALSE;
TCHAR * variable = NULL;
+ PyObject *def = NULL;
PyHFC * phfc = (PyHFC *) self;
// @pyparm string|variable||
! // @pyparm object|default||If specified, the function will return this
! // value instead of raising an error if the variable could not be fetched.
! if (!PyArg_ParseTuple(args, "s|O:GetServerVariable", &variable, &def))
return NULL;
***************
*** 212,217 ****
bRes = phfc->m_pfc->GetServerVariable(variable, buf, &bufsize);
Py_END_ALLOW_THREADS
! if (!bRes)
return SetPyHFCError("GetServerVariable");
}
return PyString_FromStringAndSize(buf, bufsize);
--- 215,225 ----
bRes = phfc->m_pfc->GetServerVariable(variable, buf, &bufsize);
Py_END_ALLOW_THREADS
! if (!bRes) {
! if (def) {
! Py_INCREF(def);
! return def;
! }
return SetPyHFCError("GetServerVariable");
+ }
}
return PyString_FromStringAndSize(buf, bufsize);
|