[albatross-users] Simple random mode demo app
Matt Goodall
matt at pollenation.net
Tue Jun 3 09:00:11 EST 2003
On Mon, 2003-06-02 at 01:58, Dave Cole wrote:
> > Sorry, the 1st URL should be
> > http://mattgoodall.dyndns.org/~matt/albatross/test/test.py.
>
> Had a bit of a play and looked at some of the code.
>
> I very much like the code that transparently handles cgi and
> mod_python deployment. One change though:
>
> if __name__ == '__main__':
> # CGI entry point
> from albatross.cgiapp import Request
> app = App()
> app.run(Request())
> else:
> # mod_python entry point
> from albatross.apacheapp import Request
> def handler(req):
> app = App()
> return app.run(Request(req))
>
> The mod_python code should be changed to this:
>
> # mod_python entry point
> from albatross.apacheapp import Request
> app = App()
> def handler(req):
> return app.run(Request(req))
>
> If you instantiate the application once then you get the benefit of
> caching of both templates and page modules.
Oh yeah, thanks for spotting that.
Incidentally, I've started a FastCGI Request class based on the fcgi
module. The basics are working (i.e. it serves a page) but I have not
tried much more with it yet. fcgi seems quite nice, especially since it
works for both standard CGI and FastCGI. Anyway, once I know it's
working I'll post it to the list.
>
> > > * Using the tree tag to display a categorised view of what's in
> > > the test app.
>
> Nice use of style sheets to indent.
>
> > > * Custom tags: one that inserts the current time, one that
> > > displays its content in a nicely coloured box and one that
> > > caches the content to disk for a period of time.
>
> The content caching tag is a work of genius.
Thanks :) although I admit to seeing the idea in some JSP taglib.
Albatross custom tags are **so** simple compared to JSP taglibs although
they are also a bit simpler.
>
> Maybe you could expand on the idea and implement a content cache mixin
> that could be inherited by the application class. This would then
> ensure that the cached content was loaded only once (for mod_python)
> applications.
Sounds sensible although doesn't that only make sense if the content is
cached in memory? I suppose the implementation could persist the cache
to the file system and keep a copy in memory. I would need to think
about concurrency issues but so does the FSCache class (no file
locking!). So yeah ... I'm convinced.
I was also planning on extending the cache tag to allow the "scope" of
cached content to be set i.e. per-application, per-user, etc.
>
> I would love to add a cache like that to Albatross.
I'll see what I can do to supply one then.
>
> - Dave
More information about the Albatross-users
mailing list