On Fri, 2003-06-27 at 13:37, Ian Sparks wrote:
> 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
A lot of this seems like it could be usefully done in a servlet, given
your own superclass. Like you define you own subclass of Page that
utilizes this stuff, and a servlet looks like:
class edit(MVCPage):
# URL path implied...
# Okay, lame way to define parameters...
parameters = {'id': {'required' = 1}}
permissions = {'GET': [HasRole('newsmanager')],
'POST': [HasRole('newsmanager')]}
# The processor is obviously me
# Not clear on i18n
presentation = 'news_edit.tmpl'
MVCPage does things like check the parameters, check permissions, handle
login, etc. Probably you override respond() so that it calls some
processing method, then uses the presentation variable to display the
results of that method.
The servlet model is pretty minimal, but it's also reasonably easy to
build things on top of. The one-page-one-module-one-class thing maybe
isn't always the way you want to structure your app, but it's a
relatively benign requirement. I don't think security is too bad,
because it's easy enough to make Webware only serve servlets, so you
can't really execute arbitrary modules easily. You might want to turn
off UnknownFiletypeFactory.
If you don't like the URL resolution, a factory is fairly easy to write,
and provide slightly more flexibility (but not a whole lot -- but
there's not that much more flexibility to be captured anyway at that
point).
Ian
-------------------------------------------------------
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