[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Re: RFC: CAP::Plugin::PathInfo



Ideally there would need to be a runmode evaluator in the pre_run
method that examined the requested URL and/or PATH_INFO in addition to
the HTTP method of the request. So it would not be enough to say a
PATH_INFO value of "/article" means I can method view_article. Chances
are you would want to run a different method if a "/article" request
was received using a DELETE, POST or PUT.


How I do this (with TemplateRunner and AutoRunmode) is that a URL like
my.cgi/article/index.html will display a list of articles, using the template /article/index.html.

To write an article I use
my.cgi/article/index.html?rm=write&title=blah&content=foo
(as a POST, of course).

This results in
1) calling the run-mode "write" to create the article in the database, but not outputting anything, and then 2) redirecting to the URL mycgi/article/index.html (which displays the list of articles including the new one).
I case of errors, it redirects somewhere else.

The redirect has the effect of making all pages reloadable and prevents accidental re-posts.

Run-modes are only used to update data, and can be combined with any template (I think the word here is "orthogonal").


Since both run-modes and templates (plus data files for them) are defined in external files, this system can be easily extended by adding extra run-modes and templates without touching the Perl modules, which is good if you work in a team on a site with many pages.


Thilo

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.