Improvements to modpython.

1. Be able to write binary data to any sockets, not only to ones created
from python.
2. Add support for CSmartPtr<CWebSession>
This commit is contained in:
Alexey Sokolov
2012-08-13 20:01:07 +07:00
parent d7bd8d8a04
commit fcc7839771
3 changed files with 21 additions and 18 deletions

View File

@@ -442,23 +442,6 @@ CPySocket::~CPySocket() {
Py_CLEAR(m_pyObj);
}
PyObject* CPySocket::WriteBytes(PyObject* data) {
if (!PyBytes_Check(data)) {
PyErr_SetString(PyExc_TypeError, "socket.WriteBytes needs bytes as argument");
return NULL;
}
char* buffer;
Py_ssize_t length;
if (-1 == PyBytes_AsStringAndSize(data, &buffer, &length)) {
return NULL;
}
if (Write(buffer, length)) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
}
}
template<> void TModInfo<CModPython>(CModInfo& Info) {
Info.SetWikiPage("modpython");
}