Opened 9 years ago
Closed 7 years ago
#12158 closed defect (fixed)
Skipped classes can be loaded, activated and displayed on plugin admin page
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2.3 |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Components that failed to load due to missing required dependencies would still show on the plugin admin page. |
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
Issue was found when making changes to trac-github plugin. The entry_points
configuration for the plugin was changed to:
extras_require={'oauth': ['requests_oauthlib >= 0.5']}, entry_points={'trac.plugins': [ 'github.browser = tracext.github:GitHubBrowser', 'github.loginmodule = tracext.github:GitHubLoginModule[oauth]', 'github.postcommithook = tracext.github:GitHubPostCommitHook', ]},
The GitHubLoginModule
still shows on the Plugins admin page when the dependency is not satisfied. The component can be activated when requests-oauthlib
is not installed even though it was claimed to be skipped during environment startup.
02:22:27 AM Trac[loader] DEBUG: Skipping "github.auth = tracext.github:GitHubLoginModule [oauth]": ("DistributionNotFound: requests-oauthlib>=0.5" not found) 02:22:27 AM Trac[loader] DEBUG: Loading github.browser from /home/user/Workspace/trac-github-dev/pve/lib/python2.7/site-packages/trac_github-2.1.3-py2.7.egg 02:22:27 AM Trac[loader] DEBUG: Loading github.postcommithook from /home/user/Workspace/trac-github-dev/pve/lib/python2.7/site-packages/trac_github-2.1.3-py2.7.egg
The issue seems to be that since the dependency is a method-scoped import, the GitHubLoginModule
class is added to the Component registry when other classes in the module are loaded: tags/trac-1.0.8/trac/loader.py@:68#L36. Primarily it would be nice to not show the Component on the plugin admin page when it is claimed to be skipped.
I don't know if there's a reasonable solution to this, but I just thought I would raise the issue to see if there are any ideas.
Attachments (0)
Change History (7)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
The patch works well. It seems I was wrong about the mechanism then. Since your patch is effective, the class must be created and added to the registry even when an exception occurs during entry.load
.
comment:3 by , 7 years ago
Milestone: | → 1.2.3 |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:4 by , 7 years ago
r15777 added ComponentMeta.deregister
, which could be useful here. It appears there is an error in that implementation:
-
trac/core.py
diff --git a/trac/core.py b/trac/core.py index 9731a030e..941d15587 100644
a b class ComponentMeta(type): 168 168 for interface in class_.__dict__.get('_implements', ()): 169 169 implementers = cls._registry.get(interface) 170 170 try: 171 implementers.remove(c lass_)171 implementers.remove(component) 172 172 except ValueError: 173 173 pass
comment:5 by , 7 years ago
Description: | modified (diff) |
---|
comment:6 by , 7 years ago
Proposed changes: log:rjollos.git:t12158_remove_components_from_registry.
comment:7 by , 7 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Proof-of-concept code: when dependencies are not solved, the
GitHubLoginModule
would be removed from_components
and_registry
inComponentMeta
class. Or, it would be good to mark as disabled for such classes to prevent enable components from admin panel.trac/loader.py