Opened 8 years ago
Closed 8 years ago
#12625 closed defect (fixed)
Checking permissions will fail unless trac.wiki.web_ui is imported
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2.1 |
Component: | wiki system | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: |
|
||
Internal Changes: |
Description
If trac.wiki.web_ui
isn't imported, a statement such as self.assertTrue('WIKI_VIEW' in self.req.perm)
will fail with traceback:
E.. ====================================================================== ERROR: test_trac_1_0_permission_policies (__main__.TestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "./test_case.py", line 16, in test_trac_1_0_permission_policies self.assertTrue('WIKI_VIEW' in self.req.perm) File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/perm.py", line 586, in has_permission return self._has_permission(action, resource) File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/perm.py", line 600, in _has_permission check_permission(action, perm.username, resource, perm) File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/perm.py", line 495, in check_permission for policy in self.policies: File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/config.py", line 915, in __get__ option=tag.code("[%s] %s" % (self.section, self.name)))) ConfigurationError: Cannot find implementation(s) of the <code>IPermissionPolicy</code> interface named <code>ReadonlyWikiPolicy</code>. Please check that the Component is enabled or update the option <code>[trac] permission_policies</code> in trac.ini. ---------------------------------------------------------------------- Ran 3 tests in 0.043s FAILED (errors=1)
This might be confusing to developers. Maybe we should have the following in the EnvironmentStub
initializer:
self.env.config.set('trac', 'permission_policies', 'DefaultPermissionPolicy, LegacyAttachmentPolicy')
or even:
self.env.config.set('trac', 'permission_policies', 'DefaultPermissionPolicy)
Or we could add an import to EnvironmentStub
:
import trac.wiki.web_ui
test_case.py is a minimal test module that demonstrates the behavior.
Attachments (1)
Change History (5)
by , 8 years ago
Attachment: | test_case.py added |
---|
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 8 years ago
All tests pass with the following proposed change:
-
trac/test.py
diff --git a/trac/test.py b/trac/test.py index a002aab..3bc2724 100755
a b class EnvironmentStub(Environment): 380 380 for name_or_class in disable or (): 381 381 config_key = self._component_name(name_or_class) 382 382 self.config.set('components', config_key, 'disabled') 383 self.config.set('trac', 'permission_policies', 384 'DefaultPermissionPolicy, LegacyAttachmentPolicy') 383 385 384 386 # -- logging 385 387 from trac.log import logger_handler_factory
comment:4 by , 8 years ago
API Changes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Initially I observed the behavior in DiscussionPlugin, so added [th 16007/discussionplugin/1.2/tracdiscussion/tests/__init__.py]. However, the statement appears to no longer be necessary, probably due to a change in the modules that are imported resulting in a transitive import of
trac.wiki.web_ui
.