Message2638

Author cgroves
Recipients
Date 2007-02-12.06:00:14
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This looks like a good start, but there are several issues with the integration with Jython that need to be fixed.

First, the Dialect class is a new-style class, but it looks like you've written it by hand.  All of the stuff in typeSetup should be generated by src/templates/gexpose.py and a corresponding .expose file.  You can look at PyString, PyList, PyDictionary or any of the other new style classes in core to see how things work in general.  Using the templating system will also help with the __delattr__, __findattr__ and __setattr__ implementations you have in Dialect.  Rather than implementing those as part of the class, the pieces that need custom behavior for those methods can be handled by the descriptors generated by the templates.  Unfortunately, I can't do much better than pointing you at the existing templates and their results as it's not documented at all.  

As a starting point, I'd suggest creating a new csv package in modules like the ones for sre, time and so on.  Move the other two inner classes to the new package as top level classes and redo Dialect as a generated class with a new dialect.expose in src/templates output to there.  If Dialect needs to be subclassed, it'll need a dialect.derived as well.  You can see the results of the *derived in all of the *Derived.java classes for the newstyle classes.  They just allow methods to be overridden by subclasses of builtin types.  After that, _csv.java will be mostly a shell referencing the functionality in the actual object classes.  

A better method for handling all of the optional arguments to the constructor is to use the getPyObject(int pos, PyObject default) and include the default values you're currently including earlier in the constructor as PyObjects passed to the getPyObject method as default.  Then use Py.py2<type> to turn it into the type you expect.  As a bonus, this correctly handles checking that the passed in kwarg is of the right type and allows you to pass in a message to be reported in the TypeError if it's inappropriate.

Feel free to ask any general questions about the new style stuff on jython-dev.  They definitely need more exposure and documentation.  Actually, any general questions about internal jython usage would be good for the jython-dev list.  I'd only comment on here if it's specific to the csv api.  
History
Date User Action Args
2008-02-20 17:18:39adminlinkissue1650802 messages
2008-02-20 17:18:39admincreate