views:

186

answers:

3

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)?

+1  A: 

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.

Simon Groenewolt
We have taken care of the user integration, yes (we basically don't integrate the two). What is dynamic about the header and footer? Hmmm... The footer is static, but generated with PHP (so that could be cached). The header is dynamic: it shows whether the user is logged in on the site (which is not necessary, okay) and the language (not applicable for Trac).
Franz
if you only want to show if the user if logged in I would make a static copy of the header and footer and replace the part that shows whether or not the user is logged in by an AJAX call.
Simon Groenewolt
+1  A: 

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.

jcdyer
+1 That is a good idea. However, the header script includes some other (PHP) stuff for getting the user object etc. to know which link to show and so on... That makes it a little more difficult. Or am I forgetting something?
Franz
A: 

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.

sli