Opinions, please: Repository module

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Sun Jan 5 18:21:52 EST 2003


andy <andy at eastonwest.co.uk> writes:
> I'm working on a little project - for my kids, actually - and I had
> a need to code a module to provide a 'central network place to store
> miscellaneous stuff'.  No security or reliablility assurance is
> required either.

If you're exposing it to the internet you really better have some security
to keep dipwads from taking over the server.

> I googled for an existing module, but found none simple enough (got
> lots of interesting stuff about distributed processing systems and
> so on though)...

Something wrong with xmlrpc over http using urllib or something like that?

> I realised I was going to have to bite the bullet and learn to use
> sockets.  I was off work for the christmas break, 9 days or so, and
> spent much of this time digging, until I was totally googled out.

See above

> It uses sockets, and is loosely based on an old chat-server example
> by J.  Strout (www.strout.net), so it uses a round-robin approach,
> with the sockets in non-blocking mode.  I specifically wanted to
> code this myself, pig-headed that I am, to learn a bit of the
> practicalities of socket programming; yes I know I could have used
> SocketServer, Twisted or any number of other modules hanging round
> there in cyberspace.  However, as I said, I wanted to know how it
> worked from the /inside/.

If serving a request involves doing anything complicated, you really
want to provide some kind of concurrency, even if it's simple forking.
> 
> Requests come in as a clear-text dictionary:
> 	{"request":"...","keys":{"k":v...}}
> 
> 	These are evaluated (for convenience) by eval().  Yes, I know
> 	this is risky, but it' easy, ok.

I'd say use the XMLRPC module instead of a dictionary.  You really
should have some kind of authentication, too.
> 	
> So far only two requests are supported:
> 
> 	"set" - sets key values
> 	"query" - queries key values
> 
> The key values are stored in a dictionary by the server.

What happens if the server stops running?  If the repository isn't
persistent, it's not really a repository.

> I just /bet/ someone is going to tell me now that there's already something 
> out there which does exactly this :-(

Yes, MySQL ;-)

> Anyway, anyone interested?

It sounds like you're doing a worthwhile learning exercise but not
something really suitable for general release.




More information about the Python-list mailing list