On 20 août, 09:10, Jorge Vargas <[email protected]> wrote:
>
> the basic procedure will be
>
> def process(self,xml)
> if is_valid_xml(xml):
> create obj and save
> else:
> flash('an error has occured')
> redirect('/same page')
>
> of course it gets a little more complicated if you want to keep the
> content to display back to the user, I suggest you take a look at the
> validators, as they will allow you to simular the state when an
> application error in the posted data has happen.
Thanks for your answer,
the following methode create works, with modume lxml, it may not be
very good:
@restrict('POST')
@validate(schema=NewPageForm(), form='new')
def create(self):
# Add the new page to the database
xml = self.form_result['content']
try:
etree.fromstring("<html>%s</html>"%xml)
except:
flash( 'Erreur, xml invalide.')
return redirect_to('same page')
.........................................................
meta.Session.commit()
return redirect_to('path', id=page.id)
a solution with formencode validators and htmlfill would bee much
nicer
Thanks for your help again,
Etienne Marache
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---