Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Trac: Users

Stupid question about enabling components

 

 

Trac users RSS feed   Index | Next | Previous | View Threaded


Chris.Nelson at SIXNET

Dec 2, 2011, 12:17 PM

Post #1 of 14 (878 views)
Permalink
Stupid question about enabling components

I'm working on calendar-based scheduling in the TracJSGantt chart. I
define a IResourceCalendar interface and provide a stupid implementation
as a proof of concept. My implementation is the class SimpleCalendar in
the tracpm.py module of my plugin and elsewhere in that module, I simply do:

self.cal = SimpleCalendar(self.env)

But now I'd like to modify Team Calendar plugin to implement
IResourceCalendar. I edited calendar.py to add:

from tracjsgantt.tracpm import IResourceCalendar

then added IResourceCalendar to the list of interfaces implemented by
TeamCalendar component and added a quick, simple implementation of the
IResourceCalendar method.

My question now is, how can TracPM find the TeamCalendar implementation
of IResourceCalendar? I think I want to set up the calendar as an
extension point and then I can find them by interface name but if I only
want one active at a time, how do I disable and enable them? Where do
the names in trac.ini come from? Do I want

tracjsgantt.tracpm.SimpleCalendar = disabled

?
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


olemis at gmail

Dec 2, 2011, 12:35 PM

Post #2 of 14 (867 views)
Permalink
Re: Stupid question about enabling components [In reply to]

On Fri, Dec 2, 2011 at 3:17 PM, Chris Nelson <Chris.Nelson [at] sixnet>wrote:

> I'm working on calendar-based scheduling in the TracJSGantt chart. I
> define a IResourceCalendar interface and provide a stupid implementation as
> a proof of concept. My implementation is the class SimpleCalendar in the
> tracpm.py module of my plugin and elsewhere in that module, I simply do:
>
> self.cal = SimpleCalendar(self.env)
>
> But now I'd like to modify Team Calendar plugin to implement
> IResourceCalendar. I edited calendar.py to add:
>
> from tracjsgantt.tracpm import IResourceCalendar
>
> then added IResourceCalendar to the list of interfaces implemented by
> TeamCalendar component and added a quick, simple implementation of the
> IResourceCalendar method.
>
> My question now is, how can TracPM find the TeamCalendar implementation of
> IResourceCalendar? I think I want to set up the calendar as an extension
> point and then I can find them by interface name but if I only want one
> active at a time, how do I disable and enable them? Where do the names in
> trac.ini come from? Do I want
>
> tracjsgantt.tracpm.**SimpleCalendar = disabled
>
> ?
>

extension points do the trick and hide all the underlying magic involved
... Take a look at the code of PermissionSystem for instance , or maybe
some other @ trac.web core components , so as to see how this works .

;)

--
Regards,

Olemis

Facebook => http://www.facebook.com/olemis
Twitter => http://www.twitter.com/olemislc (@olemislc)
Blog ES => http://simelo-es.blogspot.com
Blog EN => http://simelo-en.blogspot.com
Quora => http://www.quora.com/olemis
Youtube => http://youtube.com/user/greatsoftw
Featured article : Datos de autor bajo resultados de búsqueda de
Google<http://feedproxy.google.com/~r/simelo-news/~3/k1F5K6CX91s/datos-de-autor-bajo-resultados-de.html>
Get a signature like this.
<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>
CLICK
HERE.<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


Chris.Nelson at SIXNET

Dec 2, 2011, 12:55 PM

Post #3 of 14 (866 views)
Permalink
Re: Stupid question about enabling components [In reply to]

On 12/02/2011 03:35 PM, Olemis Lang wrote:
> ...
> My question now is, how can TracPM find the TeamCalendar
> implementation of IResourceCalendar? I think I want to set up the
> calendar as an extension point and then I can find them by interface
> name but if I only want one active at a time, how do I disable and
> enable them? Where do the names in trac.ini come from? Do I want
>
> tracjsgantt.tracpm.__SimpleCalendar = disabled
>
> ?
>
>
> extension points do the trick and hide all the underlying magic involved
> ... Take a look at the code of PermissionSystem for instance , or maybe
> some other @ trac.web core components , so as to see how this works .

I can set up an extension point but my question is "where do I get the
name from that I put in trac.ini to enable/disable each instance?
Presumably, I'd use the same name in an ExtensionOption.

trac.ini:

teamcalendar.calendar.TeamCalendar = enabled
tracjsgantt.tracpm.SimpleCalendar = disabled

or in my source:

cal = ExtensionOption('TracPM',
'calendar',
IResourceCalendar,
'teamcalendar.calendar.TeamCalendar')

But those names are an educated guess and I'd rather know how to
derive/create them than hope I'm right.
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


oddsimons at gmail

Dec 2, 2011, 3:18 PM

Post #4 of 14 (873 views)
Permalink
Re: Stupid question about enabling components [In reply to]

On Dec 2, 9:55 pm, Chris Nelson <Chris.Nel...@SIXNET.com> wrote:
> On 12/02/2011 03:35 PM, Olemis Lang wrote:
>
> > ...
> >     My question now is, how can TracPM find the TeamCalendar
> >     implementation of IResourceCalendar? I think I want to set up the
> >     calendar as an extension point and then I can find them by interface
> >     name but if I only want one active at a time, how do I disable and
> >     enable them? Where do the names in trac.ini come from? Do I want
>
> >     tracjsgantt.tracpm.__SimpleCalendar = disabled
>
> >     ?
>
> > extension points do the trick and hide all the underlying magic involved
> > ... Take a look at the code of PermissionSystem for instance , or maybe
> > some other @ trac.web core components , so as to see how this works .
>
> I can set up an extension point but my question is "where do I get the
> name from that I put in trac.ini to enable/disable each instance?
> Presumably, I'd use the same name in an ExtensionOption.
>
> trac.ini:
>
>    teamcalendar.calendar.TeamCalendar = enabled
>    tracjsgantt.tracpm.SimpleCalendar = disabled
>
> or in my source:
>
>      cal = ExtensionOption('TracPM',
>                            'calendar',
>                            IResourceCalendar,
>                            'teamcalendar.calendar.TeamCalendar')
>
> But those names are an educated guess and I'd rather know how to
> derive/create them than hope I'm right.

The trac.ini config [component] sections should contain the full
python name/namespace of the class, module or package. So if
tracjsgantt.tracpm.SimpleCalendar is an actual component implementing
one or more interface (because tracjsgantt/tracpm.py defines or
imports a SimpleCalendar class), it will be enabled if trac.ini is
configured to enable it; as "tracjsgantt.tracpm.SimpleCalendar =
enabled", or enabling at some wildcard pattern like
"tracjsgantt.tracpm.* = enabled" to enable all classes in the module.

:::simon

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


Chris.Nelson at SIXNET

Dec 3, 2011, 5:26 AM

Post #5 of 14 (862 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On 12/02/2011 06:18 PM, osimons wrote:
> On Dec 2, 9:55 pm, Chris Nelson<Chris.Nel...@SIXNET.com> wrote:
>> I can set up an extension point but my question is "where do I get the
>> name from that I put in trac.ini to enable/disable each instance?
>> Presumably, I'd use the same name in an ExtensionOption.
>>
>> trac.ini:
>>
>> teamcalendar.calendar.TeamCalendar = enabled
>> tracjsgantt.tracpm.SimpleCalendar = disabled
>>
>> or in my source:
>>
>> cal = ExtensionOption('TracPM',
>> 'calendar',
>> IResourceCalendar,
>> 'teamcalendar.calendar.TeamCalendar')
>>
>> But those names are an educated guess and I'd rather know how to
>> derive/create them than hope I'm right.
>
> The trac.ini config [component] sections should contain the full
> python name/namespace of the class, module or package. So if
> tracjsgantt.tracpm.SimpleCalendar is an actual component implementing
> one or more interface (because tracjsgantt/tracpm.py defines or
> imports a SimpleCalendar class), it will be enabled if trac.ini is
> configured to enable it; as "tracjsgantt.tracpm.SimpleCalendar =
> enabled", or enabling at some wildcard pattern like
> "tracjsgantt.tracpm.* = enabled" to enable all classes in the module.

What about the name I give to ExtensionOption? I tried
teamcalendar.calendar.TeamCalendar and got errors. Is there any way to
inspect for the name? Have the plugin do something like:

self.env.log.info("Hi, I'm %s" % myName())

?
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


olemis at gmail

Dec 3, 2011, 9:50 PM

Post #6 of 14 (856 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On Sat, Dec 3, 2011 at 8:26 AM, Chris Nelson <Chris.Nelson [at] sixnet>wrote:

> On 12/02/2011 06:18 PM, osimons wrote:
>
>> On Dec 2, 9:55 pm, Chris Nelson<Chris.Nel...@SIXNET.com**> wrote:
>>
>>> I can set up an extension point but my question is "where do I get the
>>>
>>> name from that I put in trac.ini to enable/disable each instance?
>>> Presumably, I'd use the same name in an ExtensionOption.
>>>
>>> trac.ini:
>>>
>>> teamcalendar.calendar.**TeamCalendar = enabled
>>> tracjsgantt.tracpm.**SimpleCalendar = disabled
>>>
>>> or in my source:
>>>
>>> cal = ExtensionOption('TracPM',
>>> 'calendar',
>>> IResourceCalendar,
>>> 'teamcalendar.calendar.**TeamCalendar')
>>>
>>> But those names are an educated guess and I'd rather know how to
>>> derive/create them than hope I'm right.
>>>
>>
>>
ExtensionPoint makes the magic by itself and loads the components for you,
but does not provide access to read entries under components section . If
you want to read that I think you should consider using env.config object .
If you want to know whether a given component is enabled , there's one such
method somewhere AFAICR in ComponentManager or its metaclass (if any ;).

CMIIW guys
;)

--
Regards,

Olemis

Facebook => http://www.facebook.com/olemis
Twitter => http://www.twitter.com/olemislc (@olemislc)
Blog ES => http://simelo-es.blogspot.com
Blog EN => http://simelo-en.blogspot.com
Quora => http://www.quora.com/olemis
Youtube => http://youtube.com/user/greatsoftw


Featured article : Adios Google Wave ... vivirás en nuestros servidores
http://simelo-es.blogspot.com/2011/11/adios-google-wave-viviras-en-nuestros_24.html
Get a signature like this.
<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>
CLICK
HERE.<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


olemis at gmail

Dec 3, 2011, 9:59 PM

Post #7 of 14 (855 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On Sat, Dec 3, 2011 at 8:26 AM, Chris Nelson <Chris.Nelson [at] sixnet>wrote:

> On 12/02/2011 06:18 PM, osimons wrote:
>
>> On Dec 2, 9:55 pm, Chris Nelson<Chris.Nel...@SIXNET.com**> wrote:
>>
>>> I can set up an extension point but my question is "where do I get the
>>>
>>> name from that I put in trac.ini to enable/disable each instance?
>>> Presumably, I'd use the same name in an ExtensionOption.
>>>
>>> trac.ini:
>>>
>>> teamcalendar.calendar.**TeamCalendar = enabled
>>> tracjsgantt.tracpm.**SimpleCalendar = disabled
>>>
>>> or in my source:
>>>
>>> cal = ExtensionOption('TracPM',
>>> 'calendar',
>>> IResourceCalendar,
>>> 'teamcalendar.calendar.**TeamCalendar')
>>>
>>> But those names are an educated guess and I'd rather know how to
>>> derive/create them than hope I'm right.
>>>
>>
>>
ExtensionPoint makes the magic by itself and loads the components for you,
but does not provide access to read entries under components section . If
you want to read that I think you should consider using env.config object .
If you want to know whether a given component is enabled , there's one such
method somewhere AFAICR in ComponentManager or its metaclass (if any ;).

CMIIW guys
;)

--
Regards,

Olemis

Facebook => http://www.facebook.com/olemis
Twitter => http://www.twitter.com/olemislc (@olemislc)
Blog ES => http://simelo-es.blogspot.com
Blog EN => http://simelo-en.blogspot.com
Quora => http://www.quora.com/olemis
Youtube => http://youtube.com/user/greatsoftw


Featured article : Adios Google Wave ... vivirás en nuestros servidores
http://simelo-es.blogspot.com/2011/11/adios-google-wave-viviras-en-nuestros_24.html
Get a signature like this.
<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>
CLICK
HERE.<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


Chris.Nelson at SIXNET

Dec 5, 2011, 4:57 AM

Post #8 of 14 (840 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On 12/04/2011 12:59 AM, Olemis Lang wrote:
> On Sat, Dec 3, 2011 at 8:26 AM, Chris Nelson <Chris.Nelson [at] sixnet
> <mailto:Chris.Nelson [at] sixnet>> wrote:
> On 12/02/2011 06:18 PM, osimons wrote:
> On Dec 2, 9:55 pm, Chris Nelson<Chris.Nel...@SIXNET.com__> wrote:
>
> I can set up an extension point but my question is "where do
> I get the
>
> name from that I put in trac.ini to enable/disable each
> instance?
> Presumably, I'd use the same name in an ExtensionOption.
>
> trac.ini:
>
> teamcalendar.calendar.__TeamCalendar = enabled
> tracjsgantt.tracpm.__SimpleCalendar = disabled
>
> or in my source:
>
> cal = ExtensionOption('TracPM',
> 'calendar',
> IResourceCalendar,
> 'teamcalendar.calendar.TeamCalendar')
>
> But those names are an educated guess and I'd rather know how to
> derive/create them than hope I'm right.
>
> ExtensionPoint makes the magic by itself and loads the components for
> you, ...

But what about ExtensionOption? My example above fails though that
seems the right path by code inspection.


--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


olemis at gmail

Dec 5, 2011, 6:06 AM

Post #9 of 14 (836 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On Mon, Dec 5, 2011 at 7:57 AM, Chris Nelson <Chris.Nelson [at] sixnet> wrote:
>
> On 12/04/2011 12:59 AM, Olemis Lang wrote:
>>
>> On Sat, Dec 3, 2011 at 8:26 AM, Chris Nelson <Chris.Nelson [at] sixnet
>> <mailto:Chris.Nelson [at] sixnet>> wrote:
>>    On 12/02/2011 06:18 PM, osimons wrote:
>>        On Dec 2, 9:55 pm, Chris Nelson<Chris.Nel...@SIXNET.com__> wrote:
>>
>>            I can set up an extension point but my question is "where do
>>            I get the
>>
>>            name from that I put in trac.ini to enable/disable each
>>            instance?
>>            Presumably, I'd use the same name in an ExtensionOption.
>>
>>            trac.ini:
>>
>>            teamcalendar.calendar.__TeamCalendar = enabled
>>            tracjsgantt.tracpm.__SimpleCalendar = disabled
>>
>>
>>            or in my source:
>>
>>            cal = ExtensionOption('TracPM',
>>            'calendar',
>>            IResourceCalendar,
>>            'teamcalendar.calendar.TeamCalendar')
>>
>>            But those names are an educated guess and I'd rather know how to
>>            derive/create them than hope I'm right.
>>
>> ExtensionPoint makes the magic by itself and loads the components for
>> you, ...
>
>
> But what about ExtensionOption?  My example above fails though that seems the right path by code inspection.
>
>

I think you are missing the point here that ExtensionOption offers a
way to instantiate Components by relying on Python descriptors magic .
Hence that's not the way to go if you want to list the entries under
[components] section in trac.ini . I mentioned before you have
basically two ways to go :

- Use `env.config` object so as to read information in trac.ini file directly
- Use  `ComponentMeta._registry` to list the classes implementing a
given interface
  (review the code for `ExtensionPoint.extensions` method for further details ;)
  and then invoke `ComponentManager.is_component_enabled` so as to
  know whether that particular class is enabled/disabled in that particular
  Trac environment.

Hope this will help.

--
Regards,

Olemis

Facebook => http://www.facebook.com/olemis
Twitter => http://www.twitter.com/olemislc (@olemislc)
Blog ES => http://simelo-es.blogspot.com
Blog EN => http://simelo-en.blogspot.com
Quora => http://www.quora.com/olemis
Youtube => http://youtube.com/user/greatsoftw

Get a signature like this. CLICK HERE.

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


Chris.Nelson at SIXNET

Dec 5, 2011, 6:37 AM

Post #10 of 14 (833 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On 12/05/2011 09:06 AM, Olemis Lang wrote:
> On Mon, Dec 5, 2011 at 7:57 AM, Chris Nelson<Chris.Nelson [at] sixnet> wrote:
> I think you are missing the point here that ExtensionOption offers a
> way to instantiate Components by relying on Python descriptors magic .
> Hence that's not the way to go if you want to list the entries under
> [components] section in trac.ini . I mentioned before you have
> basically two ways to go :
>
> - Use `env.config` object so as to read information in trac.ini file directly
> - Use `ComponentMeta._registry` to list the classes implementing a
> given interface
> (review the code for `ExtensionPoint.extensions` method for further details ;)
> and then invoke `ComponentManager.is_component_enabled` so as to
> know whether that particular class is enabled/disabled in that particular
> Trac environment.

I understand there are several ways to do this. If I wanted multiple
listeners or processors or whatever, I could use an ExtensionPoint and
iterate over all the enabled implementations. But what I want is a
configurable single handler. I believe that the way to do that is an
ExtensionOption. I've used that successfully for functions in my own
plugin but when I try to instantiate an implementation in another
plugin, it fails.

The class TeamCalendar is implemented in the module calendar.py in the
plugin teamcalendar but when I pass "teamcalendar.calendar.TeamCalendar'
to ExtensionOption, it fails to find the class.

Cannot find an implementation of the "IResourceCalendar" interface
named "teamcalendar.calendar.TeamCalendar". Please update the
option TracPM.calendar in trac.ini.

How can I find the real name of the class?

Chris
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


olemis at gmail

Dec 5, 2011, 6:51 AM

Post #11 of 14 (833 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On Mon, Dec 5, 2011 at 9:37 AM, Chris Nelson <Chris.Nelson [at] sixnet> wrote:
>
> On 12/05/2011 09:06 AM, Olemis Lang wrote:
>>
>> On Mon, Dec 5, 2011 at 7:57 AM, Chris Nelson<Chris.Nelson [at] sixnet>  wrote:
>> I think you are missing the point here that ExtensionOption offers a
>> way to instantiate Components by relying on Python descriptors magic .
>> Hence that's not the way to go if you want to list the entries under
>> [components] section in trac.ini . I mentioned before you have
>> basically two ways to go :
>>
>> - Use `env.config` object so as to read information in trac.ini file directly
>> - Use  `ComponentMeta._registry` to list the classes implementing a
>> given interface
>>   (review the code for `ExtensionPoint.extensions` method for further details ;)
>>   and then invoke `ComponentManager.is_component_enabled` so as to
>>   know whether that particular class is enabled/disabled in that particular
>>   Trac environment.
>
>
> I understand there are several ways to do this. If I wanted multiple listeners or processors or whatever, I could use an ExtensionPoint and iterate over all the enabled implementations.  But what I want is a configurable single handler.  I believe that the way to do that is an ExtensionOption.  I've used that successfully for functions in my own plugin but when I try to instantiate an implementation in another plugin, it fails.
>
> The class TeamCalendar is implemented in the module calendar.py in the plugin teamcalendar but when I pass "teamcalendar.calendar.TeamCalendar' to ExtensionOption, it fails to find the class.
>
>   Cannot find an implementation of the "IResourceCalendar" interface
>   named "teamcalendar.calendar.TeamCalendar".  Please update the
>   option TracPM.calendar in trac.ini.
>
> How can I find the real name of the class?
>

In that case you should use trac.config.ExtensionOption descriptors ,
rather than defining extension points
;)

--
Regards,

Olemis

Facebook => http://www.facebook.com/olemis
Twitter => http://www.twitter.com/olemislc (@olemislc)
Blog ES => http://simelo-es.blogspot.com
Blog EN => http://simelo-en.blogspot.com
Quora => http://www.quora.com/olemis
Youtube => http://youtube.com/user/greatsoftw

Featured article : Datos de autor bajo resultados de búsqueda de Google
http://feedproxy.google.com/~r/simelo-news/~3/k1F5K6CX91s/datos-de-autor-bajo-resultados-de.html
Get a signature like this. CLICK HERE.

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


olemis at gmail

Dec 5, 2011, 6:53 AM

Post #12 of 14 (830 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On Mon, Dec 5, 2011 at 9:51 AM, Olemis Lang <olemis [at] gmail> wrote:
> On Mon, Dec 5, 2011 at 9:37 AM, Chris Nelson <Chris.Nelson [at] sixnet> wrote:
>>
>> On 12/05/2011 09:06 AM, Olemis Lang wrote:
>>>
>>> On Mon, Dec 5, 2011 at 7:57 AM, Chris Nelson<Chris.Nelson [at] sixnet>  wrote:
>>> I think you are missing the point here that ExtensionOption offers a
>>> way to instantiate Components by relying on Python descriptors magic .
>>> Hence that's not the way to go if you want to list the entries under
>>> [components] section in trac.ini . I mentioned before you have
>>> basically two ways to go :
>>>
>>> - Use `env.config` object so as to read information in trac.ini file directly
>>> - Use  `ComponentMeta._registry` to list the classes implementing a
>>> given interface
>>>   (review the code for `ExtensionPoint.extensions` method for further details ;)
>>>   and then invoke `ComponentManager.is_component_enabled` so as to
>>>   know whether that particular class is enabled/disabled in that particular
>>>   Trac environment.
>>
>>
>> I understand there are several ways to do this. If I wanted multiple listeners or processors or whatever, I could use an ExtensionPoint and iterate over all the enabled implementations.  But what I want is a configurable single handler.  I believe that the way to do that is an ExtensionOption.  I've used that successfully for functions in my own plugin but when I try to instantiate an implementation in another plugin, it fails.
>>
>> The class TeamCalendar is implemented in the module calendar.py in the plugin teamcalendar but when I pass "teamcalendar.calendar.TeamCalendar' to ExtensionOption, it fails to find the class.
>>
>>   Cannot find an implementation of the "IResourceCalendar" interface
>>   named "teamcalendar.calendar.TeamCalendar".  Please update the
>>   option TracPM.calendar in trac.ini.
>>
>> How can I find the real name of the class?
>>
>
> In that case you should use trac.config.ExtensionOption descriptors ,
> rather than defining extension points
> ;)
>

Or maybe trac.config.OrderedExtensionsOption descriptors if multiple
values are allowed,

--
Regards,

Olemis

Facebook => http://www.facebook.com/olemis
Twitter => http://www.twitter.com/olemislc (@olemislc)
Blog ES => http://simelo-es.blogspot.com
Blog EN => http://simelo-en.blogspot.com
Quora => http://www.quora.com/olemis
Youtube => http://youtube.com/user/greatsoftw

Featured article : Datos de autor bajo resultados de búsqueda de Google
http://feedproxy.google.com/~r/simelo-news/~3/k1F5K6CX91s/datos-de-autor-bajo-resultados-de.html
Get a signature like this. CLICK HERE.

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


Chris.Nelson at SIXNET

Dec 5, 2011, 8:17 AM

Post #13 of 14 (838 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On 12/05/2011 09:51 AM, Olemis Lang wrote:
> On Mon, Dec 5, 2011 at 9:37 AM, Chris Nelson<Chris.Nelson [at] sixnet> wrote:
>>
>> On 12/05/2011 09:06 AM, Olemis Lang wrote:
>>>
>>> On Mon, Dec 5, 2011 at 7:57 AM, Chris Nelson<Chris.Nelson [at] sixnet> wrote:
>>> I think you are missing the point here that ExtensionOption offers a
>>> way to instantiate Components by relying on Python descriptors magic .
>>> Hence that's not the way to go if you want to list the entries under
>>> [components] section in trac.ini . I mentioned before you have
>>> basically two ways to go :
>>>
>>> - Use `env.config` object so as to read information in trac.ini file directly
>>> - Use `ComponentMeta._registry` to list the classes implementing a
>>> given interface
>>> (review the code for `ExtensionPoint.extensions` method for further details ;)
>>> and then invoke `ComponentManager.is_component_enabled` so as to
>>> know whether that particular class is enabled/disabled in that particular
>>> Trac environment.
>>
>>
>> I understand there are several ways to do this. If I wanted multiple listeners or processors or whatever, I could use an ExtensionPoint and iterate over all the enabled implementations. But what I want is a configurable single handler. I believe that the way to do that is an ExtensionOption. I've used that successfully for functions in my own plugin but when I try to instantiate an implementation in another plugin, it fails.
>>
>> The class TeamCalendar is implemented in the module calendar.py in the plugin teamcalendar but when I pass "teamcalendar.calendar.TeamCalendar' to ExtensionOption, it fails to find the class.
>>
>> Cannot find an implementation of the "IResourceCalendar" interface
>> named "teamcalendar.calendar.TeamCalendar". Please update the
>> option TracPM.calendar in trac.ini.
>>
>> How can I find the real name of the class?
>>
>
> In that case you should use trac.config.ExtensionOption descriptors ,
> rather than defining extension points
> ;)

I'm not using an ExtensionPoint. I mention that only because I
understand that is a way to have pluggable interfaces. I don't know
what a "trac.config.ExtensionOption descriptor" is.

My trac.ini says:

[TracPM]
...
calendar = teamcalendar.calendar.TeamCalendar

and my code says:

cal = ExtensionOption('TracPM', 'calendar',
IResourceCalendar, 'SimpleCalendar')

and I see:

Cannot find an implementation of the "IResourceCalendar" interface
named "teamcalendar.calendar.TeamCalendar". Please update the
option TracPM.calendar in trac.ini.

If I remove the trac.ini entry, and change the code to:

cal = ExtensionOption('TracPM', 'calendar',
IResourceCalendar,
'teamcalendar.calendar.TeamCalendar')

I get the same error.

If I try to import teamcalendar.calendar.TeamCalendar into
tracjsgantt/tracpm.py and change to:

cal = TeamCalendar(self.env)

TracJSGantt won't even load. The page says:

No macro or processor named 'TracJSGanttChart' found

and my trac.log says:

2011-12-05 11:14:14,029 Trac[loader] ERROR: Skipping "tracjsgantt =
tracjsgantt": (can't import "ImportError: cannot import name
IResourceCalendar")

I don't know what's missing!

Chris
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


olemis at gmail

Dec 5, 2011, 8:50 AM

Post #14 of 14 (828 views)
Permalink
Re: Re: Stupid question about enabling components [In reply to]

On Mon, Dec 5, 2011 at 11:17 AM, Chris Nelson <Chris.Nelson [at] sixnet>
wrote:
> On 12/05/2011 09:51 AM, Olemis Lang wrote:
>> On Mon, Dec 5, 2011 at 9:37 AM, Chris Nelson<Chris.Nelson [at] sixnet>
>> wrote:
>>> On 12/05/2011 09:06 AM, Olemis Lang wrote:
>>>> On Mon, Dec 5, 2011 at 7:57 AM, Chris Nelson<Chris.Nelson [at] sixnet>
>>>> wrote:
>>>> I think you are missing the point here that ExtensionOption offers a
>>>> way to instantiate Components by relying on Python descriptors magic .
>>>> Hence that's not the way to go if you want to list the entries under
>>>> [components] section in trac.ini . I mentioned before you have
>>>> basically two ways to go :
>>>>
>>>> - Use `env.config` object so as to read information in trac.ini file
>>>> directly
>>>> - Use `ComponentMeta._registry` to list the classes implementing a
>>>> given interface
>>>> (review the code for `ExtensionPoint.extensions` method for further
>>>> details ;)
>>>> and then invoke `ComponentManager.is_component_enabled` so as to
>>>> know whether that particular class is enabled/disabled in that
>>>> particular
>>>> Trac environment.
>>>
>>> I understand there are several ways to do this. If I wanted multiple
>>> listeners or processors or whatever, I could use an ExtensionPoint and
>>> iterate over all the enabled implementations. But what I want is a
>>> configurable single handler. I believe that the way to do that is an
>>> ExtensionOption. I've used that successfully for functions in my own
plugin
>>> but when I try to instantiate an implementation in another plugin, it
fails.
>>>
>>> The class TeamCalendar is implemented in the module calendar.py in the
>>> plugin teamcalendar but when I pass
"teamcalendar.calendar.TeamCalendar' to
>>> ExtensionOption, it fails to find the class.
>>>
>>> Cannot find an implementation of the "IResourceCalendar" interface
>>> named "teamcalendar.calendar.TeamCalendar". Please update the
>>> option TracPM.calendar in trac.ini.
>>>
>>> How can I find the real name of the class?
>>>
>>
>> In that case you should use trac.config.ExtensionOption descriptors ,
>> rather than defining extension points
>> ;)
>
>
> I'm not using an ExtensionPoint. I mention that only because I understand
> that is a way to have pluggable interfaces. I don't know what a
> "trac.config.ExtensionOption descriptor" is.
>

like I supposed ... a little RTFM might save your day here ...
;)

> My trac.ini says:
>
> [TracPM]
> ...
> calendar = teamcalendar.calendar.TeamCalendar
>

Try either this

{{{

[TracPM]
...
calendar = TeamCalendar
}}}

... or maybe is it that teamcalendar.calendar.TeamCalendar component is not
enabled ?
just wondering .

> and my code says:
>
> cal = ExtensionOption('TracPM', 'calendar',
> IResourceCalendar, 'SimpleCalendar')
>

there you have it !
the bloody `ExtensionOption` monster ...
:)

> and I see:
>
> Cannot find an implementation of the "IResourceCalendar" interface
> named "teamcalendar.calendar.TeamCalendar". Please update the
> option TracPM.calendar in trac.ini.
>
>
[...]
>
> I don't know what's missing!
>

try suggestions above and , if they don't work , ask again, again , ... and
again.
Robin Hood is here to help you .
;)

--
Regards,

Olemis

Facebook => http://www.facebook.com/olemis
Twitter => http://www.twitter.com/olemislc (@olemislc)
Blog ES => http://simelo-es.blogspot.com
Blog EN => http://simelo-en.blogspot.com
Quora => http://www.quora.com/olemis
Youtube => http://youtube.com/user/greatsoftw
Get a signature like this.
<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>
CLICK
HERE.<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.

Trac users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.