On Tue, Jul 14, 2009 at 12:24 PM, Ross Mellgren <[email protected]> wrote:

> Oh now I see, that is really awesome -- I didn't realize that it properly
> kept tab/window separation, and now it makes more sense. Of course, that
> means that if I want my logic to properly maintain the separation I'll need
> to somehow tie into that separation, which seems to make that RequestVar /
> injection path you mentioned more reasonable.
>

Should this make it onto the Wiki... oh wiki gardener and folks looking for
more Lift internals... yoo hoo!


>
> I'll stick with a SessionVar for the moment as I'm just prototyping, and
> think about the RequestVar thing for later. Thanks much for the exposition.
>
> -Ross
>
> On Jul 14, 2009, at 3:19 PM, David Pollak wrote:
>
>
>
> On Tue, Jul 14, 2009 at 11:23 AM, Ross Mellgren <[email protected]> wrote:
>
>> The RequestVar sounds a bit more fun, but I'd rather not take your time --
>> I'm sure if the SessionVar becomes onerous I can toy with that. I have some
>> concerns about stability of the image URLs, actually, so using a SessionVar
>> with some stable names seems like a better idea.
>> I'm interested in learning how the state works in detail in lift though,
>> so do you mind explaining why there might be multiple instances? I assumed
>> that (session, snippet class) was one-to-one with snippet instances?
>>
>
> Open two browser tabs and in each tab browse to:
> http://demo.liftweb.net/arc
>
> In the first browser tab, enter "first" and in the second enter "second".
> Click the submit button on each.
>
> You'll see that the state of each browser tab is separate.
>
> If you do a view source and look at the form... there's a hidden field in
> the form.
>
> What's happening under the covers is that the hidden field maps to a
> function on the server.  The function tells the current Lift session that
> if, during the processing of the current request, Lift finds a snippet named
> whatever the name of the stateful snippet is named, don't create a new
> instance, but use the instance that the function holds.  In this way, the
> snippet maintains state because it's the same instance (with the same
> instance variables, etc.)
>
> But if you have two different browser windows, each has instantiated a new
> stateful snippet and each of the hidden fields maps to a different function
> that associates different instances of the stateful snippet with the snippet
> name.
>
>>
>> -Ross
>>
>> On Jul 14, 2009, at 2:18 PM, David Pollak wrote:
>>
>>
>>
>> On Tue, Jul 14, 2009 at 10:50 AM, Ross Mellgren <[email protected]> wrote:
>>
>>> darn, I was hoping I could just get away with letting Lift manage the
>>> session by virtue of managing the session snippet.
>>>
>>
>> There may be multiple stateful snippet instances for a given stateful
>> snippet within the system.  Figuring out which is which is a non-trivial
>> task for your image serving URL.
>>
>> If you really, really don't like the SessionVar idea, you can bind a
>> function to your /image request and that function can deposit a reference to
>> the current stateful snippet into a RequestVar that can be accessed during
>> the image serving process.  If you like that answer better, give me a few
>> days to whip up an example.
>>
>>
>>>
>>> Thanks for the advice.
>>>
>>> -Ross
>>>
>>> On Jul 13, 2009, at 6:38 PM, David Pollak wrote:
>>>
>>>
>>>
>>> On Mon, Jul 13, 2009 at 3:21 PM, Ross Mellgren <[email protected]> wrote:
>>>
>>>>
>>>> Hi all,
>>>>
>>>> Is there any way to get a StatefulSnippet instance for a particular
>>>> class in the current session? It looks like there's machinery in S,
>>>> LiftRules, and LiftSession to get these but they're all marked
>>>> private[http].
>>>>
>>>> I'm still getting used to Lift, so I could very well be approaching
>>>> this the wrong way (using a custom dispatch) -- I have a snippet which
>>>> manages an image editing workflow. I'd like to create a dispatch which
>>>> serves up the current version of the image(s) to the user, so I need
>>>> to dump back a raw response without any template processing.
>>>>
>>>> I could stuff the current image(s) in a SessionVar or perhaps use an
>>>> injector and RequestVar, perhaps?
>>>
>>>
>>> Your best bet is to use a SessionVar.  Put the image or a pointer to how
>>> to get the image in a SessionVar.
>>>
>>>>
>>>>
>>>> -Ross
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Lift, the simply functional web framework http://liftweb.net
>>> Beginning Scala http://www.apress.com/book/view/1430219890
>>> Follow me: http://twitter.com/dpp
>>> Git some: http://github.com/dpp
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Lift, the simply functional web framework http://liftweb.net
>> Beginning Scala http://www.apress.com/book/view/1430219890
>> Follow me: http://twitter.com/dpp
>> Git some: http://github.com/dpp
>>
>>
>>
>>
>>
>>
>>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
>
>
>
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" 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/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to