there is a lot of confusion about workflow control in controllers, in ML 
and in the TG book is not well clarified how is the correct procedure, 
and infact i've a lot of doubt about different use of:

return self.page( tg_errors, data  )
and
raise tg.redirect( tg.url("page", tg_errors=tg_errors, **data) )


In a controller we must do frequently something like:

@tg.expose()
@tg.validate( form = previous_page )
def page(self, tg_errors=None, **data):
        if tg_errors:
            pass # some error handling

        if not data.get('my_submit_button_pressed'):
            # this is the case of autosubmit widget
            return self.previous_page( tg_errors, **data  )
            raise tg.redirect( tg.url("previous_page", 
tg_errors=tg_errors, **data) )
        else:
            # proceed with workflow
            pass

This is the main structure of our workflow-controller-process.


Now ..some consideration !
------------------------------------------------------------------------
return self.previous_page( tg_errors, **data  )
Data is well passed to previous_page, validated and correclty converted 
(single , nested_widget, repeating widget, shuttle select, fieldset, etc..).
But this have a strange behaviour, if the form is used in KID with 
"${form(**form_params)}" the form_params contain always the original 
value submitted, so a command like:
 
  data['value']['mywidget'] = 'foo'
is absolutlely ignored !

i found that something like this:
<B>${form_params['value']['mywidget']}</B>
render different value from
${form(**form_params)}

where Kid get original value, is a mistery for me....

------------------------------------------------------------------------
raise tg.redirect( tg.url("previous_page", tg_errors=tg_errors, **data) )
This is the tecnique described in the docuementation, but this have  
other problem:

First of all, a big form create an impressive and too long URL !
Second the url_quote procedure convert correclty ONLY first level of 
data, if your form is a complicated tree of data (nested widget like 
fieldset or select_shuttle) all value under the first level are all 
converted in unicode !
only solution i found is a non good pythonic solution !
if isinstance ( data.get('mywidgetvalue'), unicode):
     data['mywidgetvalue'] = eval(data['mywidgetvalue'])  # FIXME: 
TERRIBLE !





does anyone clear idea about this issue ?
glauco





-- 
+------------------------------------------------------------+
                                  Glauco Uri - Programmatore
                                    glauco(at)allevatori.com 
                               
  Sfera Carta Software(r)      [EMAIL PROTECTED]
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054 
+------------------------------------------------------------+



--~--~---------~--~----~------------~-------~--~----~
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