Diez B. Roggisch wrote:

>> http://docs.turbogears.org/1.0/UnifiedControllers
>>
>> It's quite useful but unfortunately buried in the documentation.
>>     
>
> OMFG. That's one piece of ugly code.

Wait, wait!
I am trying to get rid of a similar Piece Of Ugly Code.

I feel guilty for having used that, sure, but at the time I couldn't 
cover my use cases in other ways.
The applications I see on cogbin are usually very different from my stuff.

And, despite having been well served by TG, I am still a bit confused 
about some "best practices".

My issue may be naive, but as I already had a way to handle it (by 
torturing a validator at runtime with a sharp red-hot decorator), it 
never became a priority to canonize the code.


Say I have these methods:

 >    @require(not_anonymous())
 >    @expose('project.templates.report')
 >    def index(self, tg_errors, **kw):
 >        ....
 >
 >    @require(not_anonymous())
 >    @expose()
 >    @validate(form=nice_report_form)
 >    @error_handler(index)
 >    def retrieve_report(self, **data):
 >        try:
 >            ret = report.generate_report(**data)
 >            return ret
 >        except XLSError, msg:
 >            flash.warning(msg)
 >            raise tg.redirect('/index')


The retrieve_report() method generates an Excel file.

If there are >65k rows, or any kind of error, I'd like to reload the 
form with the flash message and the same parameters.
Conversion from POST to GET in case of post-validation errors, is ok.

Now, in the last line, the form parameters are lost, and I cannot use 
'data' since it's already been converted.
Passing

 redirect_params = cherrypy.request.params

seems to be the wrong thing to do, because the dictionary is serialized 
as such, and I am redirected to:

 '/index?' + urlencode(str(cherrypy.request.params))


In the meanwhile, cherrypy.request.original_params is empty.


This begs the question:

Am I supposed to recreate a query string from the request.params (in 
dotted notation, taking into account multi-valued widgets...) or should 
I access cherrypy's raw data as submitted to the form?
How? I already lost some time on CherryPy source.


Thank you.

-- 
This e-mail (and any attachment(s)) is strictly confidential and for use only 
by intended recipient(s).  Any use, distribution, reproduction or disclosure by 
any other person is strictly prohibited. The content of this e-mail does not 
constitute a commitment by the Company except where provided for in a written 
agreement between this e-mail addressee and the Company.
If you are not an intended recipient(s), please notify the sender promptly and 
destroy this message and its attachments without reading or saving it in any 
manner.
Any non authorized use of the content of this message constitutes a violation 
of the obligation to abstain from learning of the correspondence among other 
subjects, except for more serious offence, and exposes the person responsible 
to the relevant consequences.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to