zope, python vs apache, perl

John Mitchell johnm at magnet.com
Tue Jun 27 11:31:04 EDT 2000


Another possibility is to grab the Zope component libraries and use them
in a FastCGI environment.   That is, you'd write a more-or-less CGI script
in Python, but many things would be made easier using the Zope libs.

I used this approach for a medium-largish ad server.  It's been serving
100K ads per day for two years with no problems, and I was using *old*
libraries...

cool stuff to steal:

- easy persistent objects (no more stupid databases!  woo!)

- call any object through the web

- rich multilayered, if odd, template library.


Surprisingly, this combines to make it *very* easy to provide a remote
console to your running applicaton.  View internals, start/stop, and
provide testing information.  Leave debugging information in your live
server to make testing trivial.

For example, this bit of code renders a pretty HTML page giving a overview
of the ad service.  Uptime, number of impressions/clicks, CPU time; also
the version running, hostname, and other stuff.  Just imagine if I had
HTML skills, this leetle bit of code could translate directly into
sales...

class adServer:
	...
    # class-global:
    _showServerTemplate = HTMLFile('ad_server.dtml')

    def showServer(self, REQUEST):
        "."
        cfg = getConfig()
        uptime_secs = self.getUptime()
     
    return  self._showServerTemplate(
        title   = 'Ad Server Detail',
            adlogic_id  = vc_id,
            sys     = sys,          # sys.platform, sys.version
            config  = cfg,          # .hostname(), .is_live()
            uptime  = self.time_dhms( uptime_secs ),
            uptime_secs = uptime_secs,
            impressions = self.getRequestID(),
            mapping = self.getSysTimes()
        )
	...

Original URL:
	(server)/cgi-bin/ads/show/showServer

Here's the results:
	http://people.magnet.com/~johnm/adserver.html


I think the high-level Zope stuff is really weird, but the libraries are
great, and I'm getting better...



- j






More information about the Python-list mailing list