> You should be able to use turbogears.util.bind_args for that. Say you
> want execution to branch to "display" on an exception and
> "how_to_pass_this_while_catching_exception" being "Foo":

Thanks for the nice tips. However, in my case it doesn't work as the
value, "Foo", is known only inside "save" method. I am describing my
scenario below to try explaining the situation...

> Where is how_to_pass_this_while_catching_exception coming *from*? Why
> don't you just stick it onto the cherrypy.request object instead of
> trying to pass it as an arg?

Below I am describing my scenario. Being new to web technology, don't
know whether the approach and code is correct...would be really
thankful to have suggestions.

I am trying to develop a CMS type of application where users can create
their site, and upload documents. The typical url for uploading
documents in a user's site goes like this:

http://www.cmssite.com/usersite/documents/manage

For url redirection, I am using this:

    @expose()
    def default(self, usersite, url1=None, url2=None):
        if url1 == "documents":
            if url2 == "manage":
                return Root.doc_controller.manage(usersite)    # Here I
pass the argument!
       .
       .

Trimmed code for manage follow:

    @expose("cmssite.templates.doc_manage")
    def manage(self, usersite, tg_errors=None, tg_exceptions=None):
        if tg_errors:
            flash("Error: " + str(tg_errors))
        if tg_exceptions:
            flash("Exception: " + str(tg_exceptions))
        value = {'name' : '',
                     'content' : None,
                     'usersite' : usersite # usersite passed as a
hidden field
                    }
        return  dict(form=doc_add_form,
            action='/doc_controller/add_doc',
            value=value)

And, here is add_doc -

    @expose()
    @turbogears.validate(form=doc_add_form)
    @turbogears.error_handler(manage)
    @turbogears.exception_handler(manage)
    def add_doc(self, **data):
        usersite = Usersite.get_by(site_name=data['usersite'])
        usersite.documents.append(
            Document(name=data['name'],
                     content=data['content'].file.read()))
        session.flush()
        raise redirect(turbogears.url("/" + data['usersite'] +
"/documents/manage"))

In a sense, I am trying to push 'usersite' around as a hidden field,
avoiding using cookies or session.

> Why don't you just stick it onto the cherrypy.request object instead of
> trying to pass it as an arg?

Could not understand this, surely my noviceness. How to do that? Did
you mean cookies?

thanks a lot
sanjay


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

Reply via email to