Its a slow Friday afternoon, I hope folks will forgive my public musings.

I was looking at Zope 3's configuration XML scheme, ZCML (1) and thought to myself how 
horrible using XML files is for web-site configuration tasks.

It reminded me somewhat of a web framework I built some years ago on top of the 
Borland Delphi web capabilities which used an XML file to determine the structure of 
the URI's in the application. I found the verbosity of XML to be a real limiting 
factor : hand editing at a 1000+ line XML file was just too painful.

But the concept expressed in python doesn't seem too bad...

from webapp import WebApp, Uri

app = WebApp()
app.name = 'mysite'
app.i18n = 'translations.ini'  #Ini file containing translation text

news = Uri()
news.path = 'news'
news.processor = 'newspage.py'   #returns a namespace that will be applied to the 
template
news.i18n = 'news'               #name of ini file section containing translations
news.presentation = 'news.tmpl'  #name of template that consumes namespace provided by 
processor

app.root.appendUri(news)

newsed = Uri()
newsed.path = 'edit'
newsed.addParameter('id',required=1) #require an ID parameter to be passed
newsed.canGET.add('hasRole','newsmanager')  #Who can GET this page
newsed.canPost.add('hasRole','newsmanager') #Who can POST to this page
newsed.processor = 'newsedit.py'   
newsed.i18n = 'newsedit'               
newsed.presentation = 'news_edit.tmpl'

news.appendUri(newsed) #add as a child of news e.g. /mysite/news/edit?id=1

What I'm attempting is to force a defined structure on my WebApp so that only URI's 
that I deem valid can be called - not just files I happen to leave lying around in a 
"published" area.

I'm also trying to address things like Internationalization, separation of 
presentation from content, parameter checking and security checking so that the 
"processor" for a web page ends up being just a generator of a dictionary of content 
to be pushed into a presentation template (by whatever means).

Being able to interrogate the structure of App() from a python prompt should also be a 
big help during development.

I don't know how this fits into Webware or whether it can. There are better minds than 
mine out there and a lot more experience. Perhaps someone will pipe-up and say "it's 
been done in product X and it doesn't work for the following reasons...". As I said at 
the start of this, it's a slow friday afternoon....

ZCML :
(1) 
http://cvs.zope.org/~checkout~/Zope3/doc/zcml/meta.stx?rev=HEAD&content-type=text/plain


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to