I believe that Python will be hugely effective and valuable at implementing Web services. One need for Web services implementors is to be able to "capture" the implementation of back-end functionality and to expose it as Web services. SWIG and, in a much more modest way, dtGenerator.py can help with that "glue" task.
Generate a .c file that implements a Python extension data-type. See the function testGenerate() for a sample of usage. To use this module: (1) import it, then (2) call function generate() with the following (keyword) arguments: datatypeName=<string> -- The name of the data-type that you wish to implement. cDatatypeName=<string> -- The name of the data-type of the underlying C object. Should be a pointer type. methods=<string or sequence> -- A list of method specifications. Each specification can be a method name (a string) or a method name and method code (a tuple containing two strings). includeFileNames=<sequence of strings> -- A list of file names. A include directive will be generated for each one. Additional notes and info: See the function testGenerate (below) for an example of how to use dtGenerator. You can search for the string "???" to find all the places you should replace comments and insert your code. Toward the beginning of the file is a structure definition. If want to create these objects from another C file, then move that struct definition and a prototype for the 'new' function into a header file. Limitations: There are many, since I can't make this script as intelligent as you are. One blatant one is that it only supports getattr functions but not setattr functions. (I'm not sure I even know what that means, yet, but I'm pretty sure it's true. If you have suggestions for improvements or fixes please let me know. Dave Kuhlman [email protected]Back to top
Also take a look at the skeleton or template file that served as the basis for dtGenerator. It's in the standard Python source code distribution in Objects/xxobject.c. If you decide not to use dtGenerator.py, you might instead consider using xxobject.c as your starting point. A copy of it taken from the Python 2.1 source distribution can be found here here.
And, of course, you can contact me. Please let me know if you have suggestions,
Dave Kuhlman [email protected]Back to top