On Tue, 05 Sep 2006 18:13:37 +0300, Nuutti Kotivuori <[EMAIL PROTECTED]> wrote:
First are layout pages. These will provide the general
layout and functionality for a set of pages that will make up a
section of the site. These pages will contain the actual
html/head/body tags and such.
Second are the content pages. These pages will fit in a certain layout
and provide the actual page content to it. There will be static pages,
dynamic status pages and pages with web forms. The layout pages need
to be able to dig sections out of the content pages to fill in to the
layout; for example additional css/javascript to go into head, sidebar
items, actual content.
I think what you said sounds reasonable. Maybe have a look here:
http://trac.stiq.it/main/browser/stiq/ui/base.py
Specifically base.Base class which defines 2 class attributes: template and
sidebar that are used to fill a sidebar pane and the content pane of the
macro.html template.
Basically you just use macro.html as the basis for all the pages and fill the 2
macro slots with a different couple of templates each time.
Third are so called snippet pages. These will contain a large number
of text snippets (with markup) that are re-used on many content
pages. These snippets need to be easily includable from the content
pages. Some of the snippets are used as is, where as some of the
snippets need to be parameterised - the calling code needs to be able
to fill in some things easily.
Snippet pages are a bit troublesome. I was thinking of making a
Fragment that would have the docFactory for such a page. Then that
fragment would be instantiated where ever some snippet was to be used,
and a simple method would be called on it. This method would get the
document, get a pattern from it, call fillSlots a couple times and
return it. I could make a macro which does this based on the arguments
it receives.
Seems reasonable.
But it's all a bit in the air.
Things I'd like to avoid or achieve. I wouldn't want the actual xhtml
templates to be read many times in the life of the program - it may
even be a problem with macros if a page is read once per every pattern
used from it - so I'd like for them to be read just once. I'd like a
way to have some patterns be optional, so I could provide a default
thing to do in case they are not found. And I'd like the lookup of the
snippet patterns be somehow pre-done, so that every inclusion of a
snippet wouldn't have go to through 1000 DOM nodes to find the right
part.
Each template is rendered/parsed once and only once (not because of my code,
but that's how nevow works) unless you modify it (and it's not in a macro, in
fact if you modify a template included by a macro you have to modify the macro
too).
patterns are always optional.
pre-doing the pattern lookup can be done using self.docFactory as an argument
to inevow.IQ(self.docFactory).onePattern() either at class level or at __init__
level. Another way is to simply load a different template for the pattern at
class level calling it in another way.
pattern lookup anyway doesn't go through 1000 DOM nodes. Nevow does
precompiling of whatever it can.
So, any suggestions on how to actually go about making this happen?
What you have in mind already seems good enough.
HTH.
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web