Hi!
I have a special question.
I want to centralize, and globalize some of the website's codes.
Commonly these codes are initialize the handlers (pre-phase: check the
rights to the selected object (page), load session datas, set global
variables, initialize databases); or finalize the result (post-phase:
format it, set the type of the output, and force the main template on
it).
In the modpy in the one of the working modes I can write one handler
procedure: this procedure is makes the pre-phase, call the page
specific functions, and later get the result and force the main skin
(template) on it.
This model is makes the coding easy.
Because I can write the common init/done functions in a global module,
and they are run without my procedure call.
Example:
...
class XController...:
def Page1(self):
init()
res = ... # makeresultofpage1()
done()
def Page2(self):
init()
res = ... # makeresultofpage1()
done()
...
With post and preprocess:
def Page1(self):
return ... (some result)
def Page2(self):
return ... (some result)
...
# global handler
def preprocess():
loadsession()
checkrights()
if not haverights:
makeerror(_no_rights_)
opendatabases()
loadformvariables()
getcurrentcontroller()
getcurrentpage()
def postprocess(result):
savesession()
closedatabases()
load_main_template()
rendres = render_to_main_template(result)
writeoutput(rendres)
# The main handler
preprocess()
if haverighttopage:
result = call(currentcontroller, currentpage)
postprocess(result)
So I want to ask that how to register these procedures in pylons, or
how to avoid the repeating of some codes (like page level
"init(); .... ; done()", or same codes that initialize or finalize the
handlers - see the example 1.)?
Thanks for your help:
dd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---