Hi Chris,
perhaps a look at the official documentation on how to provide implementations for extension points, especially the topic on how to setup your python package descriptor so that trac will automatically discover your plugin. See for example http://trac.edgewall.org/wiki/TracDev/PluginDevelopment#Packagingplugins When you package your plugin, and include a proper entry point named trac.plugins to your setup.py, and also deploy your plugin on the python module path, then trac's component loader will automatically load and register your plugin with the required extension points. There is no need to import your module explicitly. Regards Carsten > In http://groups.google.com/group/trac-dev/msg/828db3da4963ed9a?hl=en, I > got a good pointer to FullBlogPlugin as a model of how to have > conditional dependencies between plugins. I'm now trying to use that > and running into problems understanding what it all means. > > I'm trying to add an IResourceCalendar implementation to TeamCalendar so > its database can drive scheduling in Trac-JSGantt. My extra is pretty > simple: > > from trac.core import Component, implements > from datetime import date > > from tracjsgantt.pmapi import IResourceCalendar > > from teamcalendar.calendar import TeamCalendar > > class TracPMConnector(Component): > implements(IResourceCalendar) > # IResourceCalendar methods > > def __init__(self): > self.teamCalendar = TeamCalendar(self.env) > > def hoursAvailable(self, when, resource = None): > # Scheduling works with time of day, Team Calendar is indexed > by days > date = when.date() > > # Get the availability for that date. > timetable = self.teamCalendar.get_timetable(date, date, [ > resource ]) > > # Available is 0.0 or 1.0 but could be any fraction of a day > # in the future. > available = timetable[date][resource] > > # Assume 8 hours per work day. > hours = available * 8.0 > > return hours > > and my setup.py is modeled on FullBlogPlugin: > > from setuptools import setup > > setup( > name = 'teamcalendar', > author = 'Martin Aspeli', > author_email = 'optil...@gmail.com', > maintainer = 'Chris Nelson', > maintainer_email = 'chris.nel...@sixnet.com', > description = 'Trac plugin for managing team availability', > version = '0.1', > license='BSD', > packages=['teamcalendar'], > extras_require={ > 'rescal': 'Trac-jsGantt>=0.10'}, > package_data={'teamcalendar': ['templates/*.html', > 'htdocs/css/*.css',]}, > entry_points = { > 'trac.plugins': [ > 'teamcalendar.calendar = teamcalendar.calendar', > 'teamcalendar.resourcecalendar = > teamcalendar.resourcecalender[rescal]' > ] > }, > install_requires = [ > ], > ) > > teamcalendar/__init__.py was: > > import calendar > > but for my resource calendar to show up in webadmin, I seem to have to > add: > > import resourcecalendar > > but that would fail if TracPM wasn't available, right? How do import my > code conditionally? > > Also, I have Trac-jsGantt 0.10 installed but even if I make 'rescal' > require 0.12, the resource calendar shows up in webadmin. How do I use > extras_require to only show the extra when the requirement is met? > > If there's a Python setup tutorial that covers this, I haven't found it > but would welcome a pointer. Thanks. > > Chris > -- > Christopher Nelson, Software Engineering Manager > Sixnet, a Red Lion business | www.sixnet.com > +1 (518) 877-5173, x135 > > -- > You received this message because you are subscribed to the Google Groups > "Trac Development" group. > To post to this group, send email to trac-dev@googlegroups.com. > To unsubscribe from this group, send email to > trac-dev+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/trac-dev?hl=en. > > -- Carsten Klein www.axn-software.de -- You received this message because you are subscribed to the Google Groups "Trac Development" group. To post to this group, send email to trac-dev@googlegroups.com. To unsubscribe from this group, send email to trac-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/trac-dev?hl=en.