There is no single webware obj that does what you want, but you can
choose the webware object that you need.
The a stateful session level ob, just create the obj and stick it in the
users session. I have some code that uses a cookie class to manage the
users data.
To retrieve it I call:
sess = self.session()
if sess.hasValue('qbCookies'):
cookies = sess.value('qbCookies')
else:
cookies = Cookies()
When I am done I call
sess.setValue('qbCookies',cookies)
It would not be too difficult to stick this in awake/sleep as a
generalized object.
-Aaron
Peter Lyons wrote:
> Tavis,
>
> By stateful, I mean retain state across multiple transactions. The
> thread safety issue is related but distinct. From what you are saying
> and tests I ran, the Webware component model seems to be analogous to
> a WebObjects stateless component. This means a small number of
> instances are created to handle all transactions in all sessions, but
> still ensuring thread safety for the duration of a request. In
> WebObjects, a standard stateful WOComponent has 1 instance dedicated
> to each session, so you can, for example, increment a hit counter in
> awake() and it will only reflect times a given user has hit that page,
> as oppesed to the same thing in a stateless component, which would
> reflect total number of hits across all sessions. So it seems that
> there is no direct analog to a stateful WOComponent. Does that seem
> correct?
> I've been adding request-specific state into the request object
> directly using request().setField(), which works quite well for me,
> but a separate container in the transaction might be cleaner and more
> flexible, so I'll try it out.
>
> Thanks,
>
> Pete
>
> Tavis Rudd wrote:
>
>> Hi Pete,
>> the default is for servlet instances to be used by only one thread at
>> a time to process one incoming request. Thus you can safely store
>> state variables in a servlet for the duration of the transaction
>> without worrying about concurrency.
>> As an aside, I've recently started storing request-specific state
>> data inside a container I add to each transaction object and have
>> found this method to be very flexible.
>>
>> Cheers,
>> tavis
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Webware-discuss mailing list
> Webware-discuss@...
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
|