Bridging PHP and Python object serialization
October 10, 2006 3:14 AM Subscribe
Bridging PHP and Python object serialization
I have a few GNU
The
Is there a way to read and manipulate the
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.
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.
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
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
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
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
posted by gsteff at 4:07 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
posted by fvw at 6:17 AM on October 10, 2006
This thread is closed to new comments.
posted by grouse at 3:24 AM on October 10, 2006