Sorry to get so late to this mail. From what I understood, things should be good with the suggested change. Thanks. I will give it a try next week.

./alex
--
.w( the_mindstorm )p.


On 3/9/06, Philipp Bracher <[email protected]> wrote:
> Thanks Philipp. I am completely puzzled by now. The MgnlContext
> represents a request/thread local context (if I am not completely
> wrong).

No it is a thread locale (not a request/thread locale). If a
container uses the same thread for sequent requests the context could
be already set (in fact this is the case). How I solve this in the
latest code can you read below.

> The Contex represents an implementation detail of how to store
> the information. Having in mind this, I read your suggestion: change
> the way the information is stored. But what I am looking for is to
> have a stable request/thread local context that is the same and is
> available for the whole request cycle. And the suggested solution
This is true. We set the context only at the start of the request

> would work only if the MgnlContext ignores subsequent calls to
> setInstance. Am I reading this wrongly?
Not exactly. Parts of code would like to run under an other context
doing something like this:

Context org = MgnlContext.getInstance();
MgnlContext.setInstance( MgnlContext.getSystemContext());
// do something with system permissions
MgnlContext.setInstance(org);

Improved solution
=================
I made again the check in the ContextSensitiveServlet superclass

if(MgnlContext.getInstance == null){
    WebContext ctx = (WebContext)FactoryUtil.getInstance
(WebContext.class)
    ctx.init(request);
    MgnlContext.setInstance(ctx);
}

To garantee that the threads context is cleaned after the request
finished I worte a UnsetContextFilter:

// call the filter chain
chain.doFilter(request, response);
// set the context to null
MgnlContext.setInstance(null);

Conclusion
==========
You can set your custom context in a filter and the standard magnolia
servlet won't overwrite it.

If you like to use always your custom context (replacing the magnolia
one) then it's better to define this in the magnolia.properties since
this is a system wide replacement and has better performance than a
filter.

Attention: the code is not yet checked in!

Hope this will be the final solution ;-D

Philipp Bracher


>
> ./alex
> --
> .w( the_mindstorm )p.
>
>
> On 3/3/06, Philipp Bracher <[email protected]> wrote:
>> Current code should be:
>>
>>          WebContext ctx = (WebContext)FactoryUtil.getInstance
>> (WebContext.class);
>>          ctx.init(request);
>>          MgnlContext.setInstance(ctx);
>>
>> And this should work.
>>
>> On 02.03.2006, at 21:11, Alexandru Popescu wrote:
>>
>>> Hi!
>>>
>>> Thanks for the comment hint Philipp, but I am not very sure how it
>>> should work considering this:
>>>
>>> [code]
>>>              Context ctx = new WebContextImpl(request);
>>>              MgnlContext.setInstance(ctx);
>>> [/code]
>>>
>>> Are you suggesting that I must create a MgnlContext like that would
>>> ignore the calls to setInstance() ?
>>>
>>> please help me understand,
>>>
>>> cheers,
>>>
>>> ./alex
>>> --
>>> .w( the_mindstorm )p.
>>>
>>> On 3/2/06, Philipp Bracher <[email protected]> wrote:
>>>>> I am creating my own context through a filter. I clean it up
>>>>> behind, so this is not a problem.
>>>> Sameer and me decided against a filter here, because it creates the
>>>> context also for cached content or the content in admindocroot as
>>>> well for docroot.
>>>>
>>>>
>>>>> I would like to here more about how I will be able to do this when
>>>>> upgrading. Please let me know of any solutions.
>>>>
>>>> If you need your own context modify magnolia.properties (see trunk)
>>>> and your implementation will get used.
>>>>
>>>> Should work well.
>>>>
>>>> Regards,
>>>>
>>>> Philipp Bracher
>>>> obinary ltd.
>>>>
>>>> -----------------------------------------------------
>>>> [EMAIL PROTECTED]       http://obinary.com
>>>> magnolia content management       http://magnolia.info
>>>> -----------------------------------------------------
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ----------------------------------------------------------------
>>>> for list details see
>>>> http://www.magnolia.info/en/magnolia/developer.html
>>>> ----------------------------------------------------------------
>>>>
>>>
>>> ----------------------------------------------------------------
>>> for list details see
>>> http://www.magnolia.info/en/magnolia/developer.html
>>> ----------------------------------------------------------------
>>
>> Regards,
>>
>> Philipp Bracher
>> obinary ltd.
>>
>> -----------------------------------------------------
>> [EMAIL PROTECTED]       http://obinary.com
>> magnolia content management      http://magnolia.info
>> -----------------------------------------------------
>>
>>
>>
>>
>>
>> ----------------------------------------------------------------
>> for list details see
>> http://www.magnolia.info/en/magnolia/developer.html
>> ----------------------------------------------------------------
>>
>
> ----------------------------------------------------------------
> for list details see
> http://www.magnolia.info/en/magnolia/developer.html
> ----------------------------------------------------------------

Regards,

Philipp Bracher
obinary ltd.

-----------------------------------------------------
[EMAIL PROTECTED]       http://obinary.com
magnolia content management      http://magnolia.info
-----------------------------------------------------





----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to