[API] New Api.getContext() method?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[API] New Api.getContext() method?

vmassol
Administrator
Hi,

I'd like to propose adding a new Api.getContext() method. Plugins are  
currently using this.context to get access to it. I'd like to add  
this method and make the context instance variable private.

This is pretty minor and I don't see any negative point of doing it  
as it's already there, just not explicit.

Let me know.

Thanks
-Vincent


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

jeremi joslin-2
Hi,
The context is local to the current request, so i don't think it's possible.

jeremi

On 2/2/07, Vincent Massol <[hidden email]> wrote:

> Hi,
>
> I'd like to propose adding a new Api.getContext() method. Plugins are
> currently using this.context to get access to it. I'd like to add
> this method and make the context instance variable private.
>
> This is pretty minor and I don't see any negative point of doing it
> as it's already there, just not explicit.
>
> Let me know.
>
> Thanks
> -Vincent
>
>
>
>
>
>
> ___________________________________________________________________________
> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
> http://fr.mail.yahoo.com
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>

--
jeremi


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

vmassol
Administrator

On Feb 2, 2007, at 1:54 PM, jeremi joslin wrote:

> Hi,
> The context is local to the current request, so i don't think it's  
> possible.

Here's the current Api class:

public class Api
{
     protected XWikiContext context;

     public Api(XWikiContext context)
     {
         this.context = context;
     }
...

All I'm suggesting is:

public class Api
{
     private XWikiContext context;

     public Api(XWikiContext context)
     {
         this.context = context;
     }

     public XWikiContext getContext()
     {
         return this.context;
     }

Nothing to do with the fact that it's local to the current request I  
think.

Thanks
-Vincent

>
> jeremi
>
> On 2/2/07, Vincent Massol <[hidden email]> wrote:
>> Hi,
>>
>> I'd like to propose adding a new Api.getContext() method. Plugins are
>> currently using this.context to get access to it. I'd like to add
>> this method and make the context instance variable private.
>>
>> This is pretty minor and I don't see any negative point of doing it
>> as it's already there, just not explicit.
>>
>> Let me know.
>>
>> Thanks
>> -Vincent
>>
>>
>>
>>
>>
>>
>> _____________________________________________________________________
>> ______
>> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail  
>> et son interface révolutionnaire.
>> http://fr.mail.yahoo.com
>>
>>
>>
>> --
>> You receive this message as a subscriber of the xwiki-
>> [hidden email] mailing list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> ObjectWeb mailing lists service home page: http://
>> www.objectweb.org/wws
>>
>>
>
>
> --
> jeremi
>
> --
> You receive this message as a subscriber of the xwiki-
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/ 
> wws





___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

jeremi joslin-2
Hi,
ok, so +1 ;-)

jeremi

On 2/2/07, Vincent Massol <[hidden email]> wrote:

>
> On Feb 2, 2007, at 1:54 PM, jeremi joslin wrote:
>
> > Hi,
> > The context is local to the current request, so i don't think it's
> > possible.
>
> Here's the current Api class:
>
> public class Api
> {
>      protected XWikiContext context;
>
>      public Api(XWikiContext context)
>      {
>          this.context = context;
>      }
> ...
>
> All I'm suggesting is:
>
> public class Api
> {
>      private XWikiContext context;
>
>      public Api(XWikiContext context)
>      {
>          this.context = context;
>      }
>
>      public XWikiContext getContext()
>      {
>          return this.context;
>      }
>
> Nothing to do with the fact that it's local to the current request I
> think.
>
> Thanks
> -Vincent
>
> >
> > jeremi
> >
> > On 2/2/07, Vincent Massol <[hidden email]> wrote:
> >> Hi,
> >>
> >> I'd like to propose adding a new Api.getContext() method. Plugins are
> >> currently using this.context to get access to it. I'd like to add
> >> this method and make the context instance variable private.
> >>
> >> This is pretty minor and I don't see any negative point of doing it
> >> as it's already there, just not explicit.
> >>
> >> Let me know.
> >>
> >> Thanks
> >> -Vincent
> >>
> >>
> >>
> >>
> >>
> >>
> >> _____________________________________________________________________
> >> ______
> >> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail
> >> et son interface révolutionnaire.
> >> http://fr.mail.yahoo.com
> >>
> >>
> >>
> >> --
> >> You receive this message as a subscriber of the xwiki-
> >> [hidden email] mailing list.
> >> To unsubscribe: mailto:[hidden email]
> >> For general help: mailto:[hidden email]?subject=help
> >> ObjectWeb mailing lists service home page: http://
> >> www.objectweb.org/wws
> >>
> >>
> >
> >
> > --
> > jeremi
> >
> > --
> > You receive this message as a subscriber of the xwiki-
> > [hidden email] mailing list.
> > To unsubscribe: mailto:[hidden email]
> > For general help: mailto:[hidden email]?subject=help
> > ObjectWeb mailing lists service home page: http://www.objectweb.org/
> > wws
>
>
>
>
>
>
> ___________________________________________________________________________
> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
> http://fr.mail.yahoo.com
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>

--
jeremi


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

Jean-Vincent Drean
In reply to this post by vmassol
+1

This would be neater.

2007/2/2, Vincent Massol <[hidden email]>:

>
> On Feb 2, 2007, at 1:54 PM, jeremi joslin wrote:
>
> > Hi,
> > The context is local to the current request, so i don't think it's
> > possible.
>
> Here's the current Api class:
>
> public class Api
> {
>      protected XWikiContext context;
>
>      public Api(XWikiContext context)
>      {
>          this.context = context;
>      }
> ...
>
> All I'm suggesting is:
>
> public class Api
> {
>      private XWikiContext context;
>
>      public Api(XWikiContext context)
>      {
>          this.context = context;
>      }
>
>      public XWikiContext getContext()
>      {
>          return this.context;
>      }
>
> Nothing to do with the fact that it's local to the current request I
> think.
>
> Thanks
> -Vincent
>
> >
> > jeremi
> >
> > On 2/2/07, Vincent Massol <[hidden email]> wrote:
> >> Hi,
> >>
> >> I'd like to propose adding a new Api.getContext() method. Plugins are
> >> currently using this.context to get access to it. I'd like to add
> >> this method and make the context instance variable private.
> >>
> >> This is pretty minor and I don't see any negative point of doing it
> >> as it's already there, just not explicit.
> >>
> >> Let me know.
> >>
> >> Thanks
> >> -Vincent
> >>
> >>
> >>
> >>
> >>
> >>
> >> _____________________________________________________________________
> >> ______
> >> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail
> >> et son interface révolutionnaire.
> >> http://fr.mail.yahoo.com
> >>
> >>
> >>
> >> --
> >> You receive this message as a subscriber of the xwiki-
> >> [hidden email] mailing list.
> >> To unsubscribe: mailto:[hidden email]
> >> For general help: mailto:[hidden email]?subject=help
> >> ObjectWeb mailing lists service home page: http://
> >> www.objectweb.org/wws
> >>
> >>
> >
> >
> > --
> > jeremi
> >
> > --
> > You receive this message as a subscriber of the xwiki-
> > [hidden email] mailing list.
> > To unsubscribe: mailto:[hidden email]
> > For general help: mailto:[hidden email]?subject=help
> > ObjectWeb mailing lists service home page: http://www.objectweb.org/
> > wws
>
>
>
>
>
>
> ___________________________________________________________________________
> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
> http://fr.mail.yahoo.com
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

vmassol
Administrator
In reply to this post by vmassol
ok, I've added the new getContext() method and moved all core code to  
use it. I've not modified the plugins in xwiki-plugins that are not  
part of the build yet.

Now we need to decide if we want to move the Api.context variable  
from protected to private (as it should be to force the usage of the  
accessor).

The only issue is that existing plugins will fail to work against the  
new version. They'll need to be modified to use getContext().

WDYT?

Note that we cannot put a deprecation on this unfortunately...

Thanks
-Vincent

On Feb 2, 2007, at 1:22 PM, Vincent Massol wrote:

> Hi,
>
> I'd like to propose adding a new Api.getContext() method. Plugins  
> are currently using this.context to get access to it. I'd like to  
> add this method and make the context instance variable private.
>
> This is pretty minor and I don't see any negative point of doing it  
> as it's already there, just not explicit.
>
> Let me know.
>
> Thanks
> -Vincent

       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

Sergiu Dumitriu
I think you should reconsider this, if I understood things correctly.

Api.getContext is a method that can be called from any velocity code, and the XWikiContext class should NOT be freely available.

On 2/2/07, Vincent Massol <[hidden email]> wrote:
ok, I've added the new getContext() method and moved all core code to
use it. I've not modified the plugins in xwiki-plugins that are not
part of the build yet.

Now we need to decide if we want to move the Api.context variable
from protected to private (as it should be to force the usage of the
accessor).

The only issue is that existing plugins will fail to work against the
new version. They'll need to be modified to use getContext().

WDYT?

Note that we cannot put a deprecation on this unfortunately...

Thanks
-Vincent

On Feb 2, 2007, at 1:22 PM, Vincent Massol wrote:

> Hi,
>
> I'd like to propose adding a new Api.getContext() method. Plugins
> are currently using this.context to get access to it. I'd like to
> add this method and make the context instance variable private.
>
> This is pretty minor and I don't see any negative point of doing it
> as it's already there, just not explicit.
>
> Let me know.
>
> Thanks
> -Vincent






___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto: [hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws




--
http://purl.org/net/sergiu

--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

vmassol
Administrator

On Feb 2, 2007, at 9:43 PM, Sergiu Dumitriu wrote:

I think you should reconsider this, if I understood things correctly.

Api.getContext is a method that can be called from any velocity code, and the XWikiContext class should NOT be freely available.

Right. Ok, so what you're saying is that getContext should be protected instead of public?

I thought about this before implementing it but then the Api constructor is public and takes a XWikiContext object. Thus I guess what we are really saying is that either we should use Context instead of XWikiContext and leave everything public or make the constructor and the getContext method protected.

BTW c.x.XWiki and c.x.XWikiContext are already available from velocity/groovy through c.x.api.XWiki.getWiki() and c.x.api.Context.getContext(), but I guess this is not right too and needs to be fixed.

Actually this is something we'll need to discuss too (the impedance mismatch between c.x.api.* and c.x.* classes).

-Vincent


On 2/2/07, Vincent Massol <[hidden email]> wrote:
ok, I've added the new getContext() method and moved all core code to
use it. I've not modified the plugins in xwiki-plugins that are not
part of the build yet.

Now we need to decide if we want to move the Api.context variable
from protected to private (as it should be to force the usage of the
accessor).

The only issue is that existing plugins will fail to work against the
new version. They'll need to be modified to use getContext().

WDYT?

Note that we cannot put a deprecation on this unfortunately...

Thanks
-Vincent

On Feb 2, 2007, at 1:22 PM, Vincent Massol wrote:

> Hi,
>
> I'd like to propose adding a new Api.getContext() method. Plugins
> are currently using this.context to get access to it. I'd like to
> add this method and make the context instance variable private.
>
> This is pretty minor and I don't see any negative point of doing it
> as it's already there, just not explicit.
>
> Let me know.
>
> Thanks
> -Vincent






___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto: [hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws




--
http://purl.org/net/sergiu

--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

Sergiu Dumitriu



I think you should reconsider this, if I understood things correctly.

Api.getContext is a method that can be called from any velocity code, and the XWikiContext class should NOT be freely available.

Right. Ok, so what you're saying is that getContext should be protected instead of public?

Yep, that's the only solution I found this far.

I thought about this before implementing it but then the Api constructor is public and takes a XWikiContext object. Thus I guess what we are really saying is that either we should use Context instead of XWikiContext and leave everything public or make the constructor and the getContext method protected.

No, Context is less powerful than XWikiCOntext, and you can't get the XWikiCOntext from the Context.

BTW c.x.XWiki and c.x.XWikiContext are already available from velocity/groovy through c.x.api.XWiki.getWiki() and c.x.api.Context.getContext(), but I guess this is not right too and needs to be fixed.

No, only for users having programming rights.

In summary:

- The Context.getContext() method can be accessed both from the velocity and java code only by the users having programming rights. It cannot be called from java without PR.
- The public Api.getContext() method can be freely called from either java or velocity, regardless of the rights.
- The protected Api.getContext() method can be freely called only from Java.

--
http://purl.org/net/sergiu

--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

vmassol
Administrator
In reply to this post by vmassol

On Feb 2, 2007, at 9:55 PM, Vincent Massol wrote:

>
> On Feb 2, 2007, at 9:43 PM, Sergiu Dumitriu wrote:
>
>> I think you should reconsider this, if I understood things correctly.
>>
>> Api.getContext is a method that can be called from any velocity  
>> code, and the XWikiContext class should NOT be freely available.
>
> Right. Ok, so what you're saying is that getContext should be  
> protected instead of public?
>
> I thought about this before implementing it but then the Api  
> constructor is public and takes a XWikiContext object. Thus I guess  
> what we are really saying is that either we should use Context  
> instead of XWikiContext and leave everything public or make the  
> constructor and the getContext method protected.
I think the protected solution is the best for now (it certainly is  
the easiest).

[snip]

-Vincent


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: [API] New Api.getContext() method?

vmassol
Administrator

On Feb 2, 2007, at 10:14 PM, Vincent Massol wrote:

>
> On Feb 2, 2007, at 9:55 PM, Vincent Massol wrote:
>
>>
>> On Feb 2, 2007, at 9:43 PM, Sergiu Dumitriu wrote:
>>
>>> I think you should reconsider this, if I understood things  
>>> correctly.
>>>
>>> Api.getContext is a method that can be called from any velocity  
>>> code, and the XWikiContext class should NOT be freely available.
>>
>> Right. Ok, so what you're saying is that getContext should be  
>> protected instead of public?
>>
>> I thought about this before implementing it but then the Api  
>> constructor is public and takes a XWikiContext object. Thus I  
>> guess what we are really saying is that either we should use  
>> Context instead of XWikiContext and leave everything public or  
>> make the constructor and the getContext method protected.
>
> I think the protected solution is the best for now (it certainly is  
> the easiest).
Fixed. I didn't put the constructor protected as this would have  
caused an issue (the XWikiDocument.newDocument wouldn't have been  
able to create a Document object).

-Vincent

       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws