Franz
Franz

Reputation: 11553

Integrate Python app into PHP site

This might sound really crazy, but still...

For our revamped project site, we want to integrate Trac (as code browser, developer wiki and issue tracker) into the site design. That is, of course, difficult, since Trac is written in Python and our site in PHP. Does anybody here know a way how to integrate a header and footer (PHP) into the Trac template (preferrably without invoking a - or rather two for header and footer - PHP process from the command line)?

Upvotes: 4

Views: 2366

Answers (3)

user13876
user13876

Reputation:

Your Python code will have access to your users' cookies. A template would be best, but if you don't have one available (or the header/footer are trivially small, or whatever), you can simply port the PHP header and footer code to Python, using the cookies that are already there to query the database or whatever you need to do.

If you want to retain your links for logging in, registering, and whatever else might be in the PHP version, simply link to the PHP side, then redirect back to Trac once PHP's done its job.

Upvotes: 0

jcdyer
jcdyer

Reputation: 19165

Abstraction is your friend.

Isolate the raw HTML from your PHP in the header and footer in a simple templating language, if possible, and write Python and PHP interfaces to your templating language. Or, reuse the work that other people have done. This chart shows that Template Attribute Language (TAL) has Python and PHP5 support.

Upvotes: 1

Simon Groenewolt
Simon Groenewolt

Reputation: 10665

The best option probably is to (re)write the header and footer using python.

If the header and footer are relatively static you can also generate them once using php (or once every x minutes) and include them from the filesystem. (You probably already thought about this and dismissed the idea because your sites are too dynamic to use this option?)

While I would not really recommend it you could also use some form of AJAX to load parts of the page, and nothing prevents you from loading this content from a php based system. That could keep all parts dynamic. Your pages will probably look ugly while loading, and you now generate more hits on the server than needed, but if it is nog a big site this might be a big.

Warning: If you have user logins on both systems you will probably run into problems with people only being logged in to half of your site.

Upvotes: 1

Related Questions