On Wed, 08 Sep 2004 10:39:08 -0400, Michael Peters
<[EMAIL PROTECTED]> wrote:

> Unless you modify every run mode of every application module to save
> their state before returning to the browser 

In my particular application, this is fairly easy.  All my runmodes
call a common method that does some processing right before the
runmode returns.  So I'd only have to modify one place to save an
extra hidden parameter or set a cookie.

What I had in mind was to have all the runmodes that need to save
their state (this can be checked in the common end of runmode method)
save it and then restore it when going back to the runmode.

> remeber where they came from. And you preferences module could check for
> this parameter and redirect them to that url after they are done.

In some cases the amount of state information that would have to be
saved would be more than the allowed length of a URL so I'm not sure
this would work.  Yeah, yeah, I know I should store this in a session
variable somewhere but with my particular hosting set-up (which
resides on a closed WAN) that's not trivial.   It's far easier to pass
the session info around in the web pages.

I don't write CGI apps for a living and this is my first time using
CGI::Application so I'm sure I've made some less than optimal design
choices.  However I'd like to get this to work without a major
overhaul of the application.  I could override CGI::Application::query
and set the __QUERY_OBJECT myself but that's not guaranteed to work if
CGI::Application gets upgraded.  I could also modify each runmode to
restore it's own state but with 29 runmodes, that's less than ideal.

--Rhet



On Wed, 08 Sep 2004 10:39:08 -0400, Michael Peters
<[EMAIL PROTECTED]> wrote:
> Rhet Turnbull wrote:
> > I would like to be able give CGI::Application a new query object after
> > new() has been called but query() seems to preclude this.  E.g. this
> > comment in the source:
> >
> > (in sub query in CGI::Application)
> > # We're only allowed to set a new query object if one does not yet exist!
> >
> > The reason I'd like to do this is that I need the user to be able to
> > jump from one runmode to another and then jump back to where they were
> > with the state restored as if they'd never left.  The specific
> > application is a "user preferences" page that's accessible from any
> > runmode.  Once they set the preferences, I want to jump back to where
> > they were.  I think I can do this by using CGI::save to save the state
> > (and stick it in a cookie) then check in cgiapp_prerun if the state
> > should be restored and restore it with a CGI::new but I need the new
> > CGI object to replace the one that CGI::Application has already
> > created.
> 
> I don't think this will work the way you intended. If you save the state
> just as you enter into the preferences page your CGI state won't reflect
> where they were, but where they want to go, ie preferences...
> 
> Unless you modify every run mode of every application module to save
> their state before returning to the browser (which would be unecessary
> most of the time and wasteful and would also cause problems if you save
> post data that then gets run again, etc) then this won't happen the way
> you want.
> 
> I think a better solution is to dynamically create the link (or form)
> that goes to the preferences page. It should add a 'redirect' parameter
> that would capture the url of where they just came to. This would then
> remeber where they came from. And you preferences module could check for
> this parameter and redirect them to that url after they are done.
> 
> This is actually the way that most login/etc pages work when you try to
> go somewhere else, but first need to login.
> 
> HTH
> 
> > Any ides how to do this.  Also, what's the reason that I can't give
> > CGI::Application a new query object anytime I want?
> 
> Don't have an answer for you there... I'm sure there was a reason though...
> 
> --
> Michael Peters
> Developer
> Plus Three, LP
> 
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
>              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to