Bridging PHP and Python object serialization
October 10, 2006 3:14 AM   Subscribe

Bridging PHP and Python object serialization

I have a few GNU mailman lists that I'd like to manipulate with a PHP-based web application.

The mailman user table appears to be stored in Python marshal format.

Is there a way to read and manipulate the mailman user database within a PHP data structure? I'd like to read the database information into a structured (key-value) PHP variable, possibly modify values, and read the information back into the mailman.

I suppose I could do stuff on the command-line, or use a PEAR Python module to run Python code, but for code management purposes it would be preferable to be able to manipulate PHP variables.

Sorry if this is a question with an easy solution. Thanks for any advice.
posted by Blazecock Pileon to Computers & Internet (7 answers total) 1 user marked this as a favorite
 
Keep in mind that the marshal format is undocumented "on purpose" as it may change between Python versions. So any solution that doesn't involve Python will not be future-proof.
posted by grouse at 3:24 AM on October 10, 2006


This also goes for [c]Pickle, the other Python serialising format. FWIW, I'd also like to know a good solution to this question!
posted by PuGZ at 3:42 AM on October 10, 2006


Would it be possible to have a Python script proxying it for you? That is, the Python script unmarshals it, then converts it to YAML / XML or similar, and lets you read/write?
posted by wackybrit at 3:43 AM on October 10, 2006


The difference is that pickle is supposed to remain backwards compatible across versions of Python. If you have something that works with a version 2 pickle file, it should work forever.
posted by grouse at 3:45 AM on October 10, 2006


Best answer: I'm shocked that I was actually able to find a solution to this, but have you looked at the Python in PHP module? It appears to do exactly what you're describing. In fact, one of the documentation slideshows on the site specifically discusses how to use it to access Mailman databases from PHP. Go to slide 28.
posted by gsteff at 4:07 AM on October 10, 2006


Response by poster: Sweet. Thanks so much.
posted by Blazecock Pileon at 4:14 AM on October 10, 2006


Have a look at YAML. It's supported in lots of languages, including Python and PHP, and the serialised form is relatively pretty and readable.
posted by fvw at 6:17 AM on October 10, 2006


« Older Is it stupid to stay on nicotine patches long term...   |   Queer eye for a big guy... Newer »
This thread is closed to new comments.