Sunday, July 24, 2005

Embed PHP in Perl or in Python

I wrote two scripts in order to put some life into the Arabeyes website, mainly in order to create and update RSS feeds with the latest CVS commits and the latest mailing lists posts. Those two feeds can then be displayed on the front page to give it a more interactive shape (and as I'm posting this, I'm asking myself why not do the same with the Planet? The feed is already there and all ;-)). As I had no real preference for a language or another, and I wanted to learn more about both, I wrote one script, ml2rss.pl, in Perl and the other, cvs2rss.py, in Python.

While writing the Python one, I became aware that I was re-writing a lot of the code that was already there, used in many other Python scripts that we use for administration. So, I did an attempt to regroup all of that common code in the aelib module. It is not complete yet, as there is at least another function that could be there too: this one sends notification emails and is used in different ways in cvs_log.py and checkuser.py. I did not do the same with the Perl scripts (yet), and won't probably do it in the near future.

However, I wanted to go even further: what we do in those scripts is mainly dealing with the MySQL database. It just happens that we already implemented all those functions (and more) in PHP, in the website code. Then why not simply use the PHP code rather then re-inventing the wheel in Perl and Python? Wrapping PHP in Perl or Python is what I had in mind.

I did some very quick googling and the results were disappointing. The most interesting one was this module for Perl. But it is nonetheless quite basic... I don't plan to spend more time on that for now. Probably the obvious thing would be to use one day a single language for the website and the admin scripts...

0 Comments:

Post a Comment

<< Home