[Trac-tickets] [The Trac Project] #1567: Cannot import custom plugins

The Trac Project noreply at edgewall.com
Mon May 16 20:01:52 EDT 2005


#1567: Cannot import custom plugins
---------------------+------------------------------------------------------
       Id:  1567     |      Status:  new                     
Component:  general  |    Modified:  Mon May 16 20:01:52 2005
 Severity:  normal   |   Milestone:                          
 Priority:  normal   |     Version:  devel                   
    Owner:  cmlenz   |    Reporter:  eblot                   
---------------------+------------------------------------------------------
 I probably missed an essential point, but I cannot load a custom plugin
 into Trac.

 There are several issues, I believe, in {{{loader.py}}}, at line 38,
 {{{load_component(name, path, globals(), locals())}}}[[BR]]
  * {{{name}}} is always equal to 'module', so how can the actual module be
 forwarded to the {{{load_component}}} method? Wouldn't it be 'value'
 instead of name?
  * {{{path}}} should be either a string or {{{None}}}. However, if
 ''path'' is not defined in the matching module section, {{{path}}} is
 returned as an empty string, not as {{{None}}}. When {{{path}}} is an
 empty string, find_module does not behave as if it is None...
  * find_module expect a path either as {{{None}}} or as a list. If
 ''path'' is defined in the matching module section, ''path'' is forwarded
 as a string, not as a list of strings, which causes the find_module to
 fail, even if the path is correct

 Whatever the way the path is given to the loader (either through 'path =
 ...' in trac.ini, or through the PYTHONPATH environment variable), the
 plugin fails to load, with the following exception:
 {{{
 Traceback (most recent call last):
   File "tracd", line 87, in ?
     main()
   File "tracd", line 69, in main
     httpd = TracHTTPServer(server_address, args, auths)
   File "d:\tmp\trac\current\Lib\site-packages\trac\web\standalone.py",
 line 150, in __init__
     env = open_environment(path)
   File "D:\tmp\trac\current\Lib\site-packages\trac\env.py", line 270, in
 open_environment
     env = Environment(env_path)
   File "D:\tmp\trac\current\Lib\site-packages\trac\env.py", line 70, in
 __init__
     load_components(self)
   File "D:\tmp\trac\current\Lib\site-packages\trac\loader.py", line 38, in
 load_components
     load_component(value, None, globals(), locals())
   File "D:\tmp\trac\current\Lib\site-packages\trac\loader.py", line 66, in
 load_component
     module = _load_module(head, module_name, module, path)
   File "D:\tmp\trac\current\Lib\site-packages\trac\loader.py", line 80, in
 _load_module
     parent and parent.__path__ or path)
 AttributeError: 'module' object has no attribute '__path__'



 }}}

 It seems that the module object returned does not contain {{{__path__}}}
 attribute (which can be verified with {{{dir(module)}}}, although this
 attribute exists for default components. The .py file is successfully
 loaded, but the loader fails to load the plugin's component. I probably
 forgot some compulsory thing, but I can't find what.

 I guess this latter point comes from my poor knowledge in Python, I'll try
 to solve in on my own.

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/1567>
The Trac Project <>


More information about the Trac-Tickets mailing list