[jifty-devel] Continuations with URL query parameters

Sean E. Millichamp sean at bruenor.org
Mon Dec 11 12:19:06 EST 2006


On Sun, 2006-12-10 at 21:58 -0500, Alex Vandiver wrote:

> Perhaps the preserve_state => 1 argument in Jifty::Web::Form::Clickable
> should pull *all* HTTP variables into the link, not just state
> variables.

Anyone have any significant objections to this change?  It will change
the current behavior, but I would argue that "preserve_state" implies
preserving all of the state.  I may look at making this change.

> On that note, check out state variables to see if they'll do what you
> want (Jifty->web->get_variable, Jifty->web->set_variable,
> Jifty::Web::Clickable->state_variable).  State variables were an
> interesting though early on, which fragments were layered on top of,
> which not much work has been done with state variables by themselves, so
> they might need some love to work the way you want.

Before I sent the email I had pondered that but didn't know how to make
it work in my situation.  I was stuck thinking I needed a way of setting
the state variable in the link from the first page to the second.  I
played around with it and now I have this in the second page
(/host/detail):

<%args>
$hostid => undef
</%args>
<%init>
my $host = SCMS::Model::Host->new();
if ( $hostid ) {
    Jifty->web->set_variable('hostid', $hostid);
} else {
    warn "Loading from get_var";
    $hostid = Jifty->web->get_variable('hostid');
    Jifty->web->set_variable('hostid', $hostid);
}
$host->load($hostid);

If hostid is passed as a query parameter (from the 'parameters' section
of the tangent link on the first page) then it is set as a state
variable.  If it is not passed (expected on the continuation return)
then it will be loaded from the state variables.  I found it necessary,
but unexpected, that I would then have to set it again.  Is that how it
is supposed to work?  Based on my reading somewhere in the docs, I
understood that state variables should be stored for the duration of the
browser session unless explicitly cleared.

Given the relative complexity of doing this, I may just resort to
embedding the ID in the URL and let the Dispatcher handle it.  At the
time though, passing it as a parameter seemed like the simpler route.

Sean




More information about the jifty-devel mailing list