Hello there,

It looks like everyone is stratching an itch nowadays.
I've written 0.01 version of any_srv. It is a rpc
client/server that takes the approach if knowing as
little as possible to serve metakit (by its approach
it could serve even something like the string
library).

It is at:

http://savannah.nongnu.org/download/pytunnel/any_srv.py
http://savannah.nongnu.org/download/pytunnel/meta_client.py

It is an asynchat server (which means it is single
threaded which is what metakit needs). My goal is to
also be able stay as close as possible to the metakit
library syntax.

Rather than explicitly map everything with code, the
client automatically forwards everything (via
getattr). Anything that is not pickleable is returned
as an object reference.

This means the client for any_srv is 100% stupid.
And the server except for importing metakit, is also
100% stupid. The advantage is that if metakit changes,
the client/server code doesn't need to know about it. 

It also support iterators. Any iterable object
references are kept as that. So, the client can
iterate through the rows as it needs to. The entire
row result from a query is not sent back.

Start the server with:
python any_srv.py

Here is example client code:
    mclient=any_server.Client()
    #Create a database:
    db = mclient.storage("datafile.mk",1)
 
    print 'Create a view'
    vw = db.getas("people[first:S,last:S,bowling:I]")
 
    print 'Add a couple of rows'
    vw.append(first='Fred',last='Flint',bowl=250)
    vw.append(first='Barney',last='Rubble',bowl=150)
 
    print 'Commit the changes to file:'
    db.commit()
 
    print 'Show a list of all people:'
    for r in vw: print r.first(), r.last(),r.bowl()   
          

    mclient.any_server_clean()

2 things to think about:
Need to explicity kill the object references with
mclient.any_server_clean()

Currently, attributes as well as methods end in (). 

The code is rough and needs to have more
features/documentation added but it seems to work
well.

Any comments would be appreciated.

john

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
_______________________________________________
metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to