Document Actions
11/28/2005
CPSMailAccess 1.2.0 released
I have released CPSMailAccess 1.2.0 today. It includes bugfixes, engine and UI enhancements.

The next steps will become very interesting because it will provide some features we wanted to have since we started the project:

  • Virtual folders classification
  • Thread manipulations
  • ...

Also, a major upcoming change will be on ajax side, as I'll refactor the javascript code to make it rely on a third party js library. This will also be helpfull to start unit testing this part of the app.

Last, I'll probably add a import feature from other mail clients, in order to grab configured filters. I've been told this was the last thing that was missing to adopt CPSMailAccess over that exotic and unfamous mail client called Thunderbird ;)

here's the annoucement: http://www.cps-project.org/sections/news/cpsmailaccess-1-2-0

Posted by Tarek Ziadé @ 11/28/2005 01:54 PM. - Categories: cps, python, semantic_web, zope1287 comments
11/05/2005
XML-RPC over Zope 3, a quick tutorial
Please read this blog entry from here

What 's XML-RPC ?

XML-RPC is a very simple Remote Procedure Control encoded in xml that can be used to interact with an application server from another program (another server, a rich client, or some Ajax'ed web Page)

More infos at wikipedia

XML-RPC in Zope 3

Zope 3 comes with a very handy approach to provide XML-RPC features. You just have to write a view class that provides methods that will be available as RPC methods.

If you are coming for Zope 2 world, please read up philliKon's slides at worldcookery (other Z3 goodies can be found there).

My First XMLRPC Package

Let's write a small Zope 3 package to provide an XML-RPC method over all server folders, that provides a folder listing.

This product is a folder composed of two files:

  • xmlprctest.py: contains the xmlrpc view class that implements the method.
  • configure.zcml: contains the configuration that will be read by Zope when it starts.
  • __init__.py: an empty file that makes the folder beeing a Package.
FolderListing View class in xmlrpctest.py 

Writing a XML-RPC view is extremely simple

from zope.app.publisher.xmlrpc import XMLRPCView

class FolderListing(XMLRPCView):
    def contents(self):
        """ returns the folder content """
        return list(self.context.keys())

The contents() method just returns the context elements.

Introspection

Zope 3 will also automatically provide three extra methods for XML-RPC Introspection, that helps on API discovering from the client:

  • listMethods(): Lists all xmlrpc methods (ie views) registered for the current object
  • methodHelp(method_name): Returns the method documentation of the given method.
  • methodSignature(method_name): Returns the method documentation of the given method.

Get more info about introspection here: introspection.

Since Python does not provide static typing, methodSignature needs a bit of help to return the signature of the method.

A method decorator called xmlrpccallable is provided and can be used on the View:

from zope.app.publisher.xmlrpc import XMLRPCView
from zope.app.xmlrpcintrospection.xmlrpcintrospection import xmlrpccallable

class FolderListing(XMLRPCView):

    @xmlrpccallable(str)
    def contents(self):
        """ returns the folder content """
        return list(self.context.keys())

The first decorator parameter is the return type, and the next parameters are the arguments type, if needeed.

Linking the view in configure.zcml

In the configuration file, we will tell Zope 3 that FolderListing() has to be instanciated and used everytime a XML-RPC call is made on a zope folder:

<configure xmlns="http://namespaces.zope.org/zope"
        xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc">
<xmlrpc:view
    for="zope.app.folder.folder.IFolder"
    methods="contents"
    class="xmlrpctest.xmlrpctest.FolderListing"
    permission="zope.ManageContent"/>
</configure>

The xmlrpc:view directive, provided by zope.app.publisher.xmlrpc hooks everything up.

Setting up the package

The three files are saved into a folder called xlmrpctest into {$INSTANCE}/lib/python.

Last but not least, a zcml file, called xmlrpctest-configure.zcml,has to be added in {$INSTANCE}/etc/package-includes/ to let zope 3 know about the package.

xmlrpctest-configure.zcml:

<include package="xmlrpctest" />
That's all, Zope can be restarted !

Trying out the XML-RPC method

Let's try out our product, with a few lines of python, using xmlrpclib:

from XMLRPCAuth import BasicAuthTransport
from xmlrpclib import ServerProxy

transport = BasicAuthTransport('admin', 'admin')
proxy = ServerProxy('http://localhost:8080/ok', transport=transport)

print 'method list:'
for method in proxy.listMethods():
    signature = proxy.methodSignature(method)[0]
    returned_type = signature[0]
    arguments_type = ', '.join(signature[1:])
    print '  + %s(%s) -> %s: %s' % (method, arguments_type, returned_type,
                                proxy.methodHelp(method).strip())

This small program will display all XML-RPC methods available on the folder ok, with their signatures.

The XMLRPCAuth package is a simple module that provides a basic authorization transport, and can be taken here: XMLRPCAuth

tziade@Tarek:/home/tziade$ python z3test.py
method list:
+ contents() -> str: returns the content of the folder
Posted by Tarek Ziadé @ 11/05/2005 02:42 AM. - Categories: zope, zope3 -  0 comments
11/01/2005
Choosing an IDE for Python (updated)
I am trying to choose a new IDE to write Python code, after a few problems I had with the *beeeep* generic editor I use.

I've read the very interesting blurg from Jonathan Ellis here but i didn't find the IDE that fits me yet. I am trying them all.

Wishlist

The perfect IDE for me needs:
  • easy encoding configuration: I do iso-8859-15 and some of the IDE out there don't want me to.
  • simple, yet powerfull, code completion. Some of them are just crazy.
  • reasonable CPU/Mem load
  • A decent learning curve 
  • good enough code cleaning: trailing spaces removal
  • bad syntax notifier: for example SPE hilites bad syntax
  • decent debugguer links, with toggles.
  • easy macro programming
  • XML, ZPT, CSS, and third party editing as well, with proper *indentation*. 4 is nice for Python, I want 2 for ZPT !
  • ...

Tried so far: drpython, SPE, Eric3, WingIde, Bluefish, BoaConstructor, Kate

  • drpython: really nice plugin, script features, i need to get deeper into it. autocompletion not really helpfull. I had to manually download and install plugins, the download UI bugged.
  • Eric3: pretty good, I miss some features though, still trying it up
  • WingIDE: really nice
  • SPE: Nice one, I had some bugs but Stani corrected them in the very same day I mentioned them.
  • Bluefish: not interesting for 100% python devel.
  • BoaConstructor: I can't get use to the UI, and had a few bugs

I won't try PyDev, i need to run other softwares when I am working ;)

Conclusion

DrPython is one of the smartest, nicest of the list in my opinion, Eric3 and WingIde are rocking too. But at this time, I go for SPE, because it is a very fast moving project, and will probably fullfill all my wishes soon.

Posted by Tarek Ziadé @ 11/01/2005 03:25 AM. - Categories: python -  0 comments
Last modified: 01/25/2005 06:15 PM

Nuxeo Bloggers: Log in!
Nuxeo - Indesko - Nuxeo 5 Project
All content is copyrighted by their author.
CPSSkins is Copyright © 2003-2006 by Jean-Marc Orliaguet. | CPS is Copyright © 2002-2006 by Nuxeo SAS.