[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security - _Proxy.c:1.1.2.12

Guido van Rossum guido@python.org
Mon, 22 Apr 2002 12:23:08 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Security
In directory cvs.zope.org:/tmp/cvs-serv14071

Modified Files:
      Tag: SecurityProxy-branch
	_Proxy.c 
Log Message:
Add doc strings.


=== Zope3/lib/python/Zope/Security/_Proxy.c 1.1.2.11 => 1.1.2.12 ===
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds,
-					 "OO:secproxy.__new__", kwlist,
+					 "OO:_Proxy.__new__", kwlist,
 					 &object, &checker))
 		return NULL;
 	self = (ProxyObject *)type->tp_alloc(type, 0);
@@ -393,6 +393,20 @@
 	proxy_setitem,				/* mp_ass_subscript */
 };
 
+static char proxy_doc[] = "\
+Security proxy class.  Constructor: _Proxy(object, checker)\n\
+where 'object' is an arbitrary object, and 'checker' is an object\n\
+whose signature is described by the IChecker interface.\n\
+A checker should have the following methods:\n\
+  check(object, operation) # operation is e.g. '__add__' or '__hash__'\n\
+  check_getattr(object, name)\n\
+  check_setattr(object, name)\n\
+  proxy(object)\n\
+The check methods should raise an exception if the operation is\n\
+disallowed.  The proxy method should return a proxy for the object\n\
+if one is needed, otherwise the object itself.\n\
+";
+
 statichere PyTypeObject
 ProxyType = {
 	PyObject_HEAD_INIT(NULL)
@@ -417,7 +431,7 @@
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
 		Py_TPFLAGS_HAVE_GC,		/* tp_flags */
-	0,					/* tp_doc */
+	proxy_doc,				/* tp_doc */
 	proxy_traverse,				/* tp_traverse */
 	0,					/* tp_clear */
 	proxy_richcompare,			/* tp_richcompare */
@@ -445,7 +459,7 @@
 
 	if (!Proxy_Check(arg)) {
 		PyErr_SetString(PyExc_TypeError,
-				"getObject argument must be a Proxy");
+				"getObject argument must be a _Proxy");
 		return NULL;
 	}
 	result = Proxy_GetObject(arg);
@@ -460,7 +474,7 @@
 
 	if (!Proxy_Check(arg)) {
 		PyErr_SetString(PyExc_TypeError,
-				"getChecker argument must be a Proxy");
+				"getChecker argument must be a _Proxy");
 		return NULL;
 	}
 	result = Proxy_GetChecker(arg);
@@ -476,7 +490,7 @@
 };
 
 static char
-module___doc__[] = "XXX";
+module___doc__[] = "Security proxy implementation.";
 
 void
 init_Proxy(void)