Edgewall Software
Modify

Opened 20 years ago

Closed 20 years ago

#1567 closed defect (fixed)

Cannot import custom plugins

Reported by: Emmanuel Blot Owned by: Christopher Lenz
Priority: normal Milestone: 0.9
Component: general Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

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())

  • 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.

Attachments (0)

Change History (3)

comment:1 by Emmanuel Blot, 20 years ago

Sorry, the latter point is not relevant (starting from the trace dump). I can now load the helloworld plugin (it fails later on, but this is not related to this bug report)

comment:2 by Christopher Lenz, 20 years ago

Milestone: 0.9
Status: newassigned

comment:3 by Christopher Lenz, 20 years ago

Resolution: fixed
Status: assignedclosed

This should be fixed in [1685]. Thanks!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.