Modify

Opened 8 years ago

Closed 8 years ago

#12891 closed defect (fixed)

Renaming a template containing a form to move it into a private wiki

Reported by: ntmlod Owned by: Nathan Lewis
Priority: normal Component: PrivateWikiPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

I'm not sure if PrivateWikiPlugin is in question in that case because it's tricky for me with multiples plugins in cross-use:

PrivateWikiPlugin 1.0.0
TracFormsPlugin 0.5dev
TracWikiNotification 0.4.2

Here is the log extract when Trac crashed while checking the permission FORM_VIEW:

2016-10-07 19:21:13,468 Trac[api] DEBUG: Attempting to protect against WIKI_VIEW
2016-10-07 19:21:13,479 Trac[api] DEBUG: Checking permission called with: action(PRIVATE_EDIT_censored), username(censored), resource(None), perm(<trac.perm.PermissionCache object at 0x30e3910>)
2016-10-07 19:21:13,479 Trac[api] DEBUG: Checking permission called with: action(PERMISSION_ADMIN), username(censored), resource(None), perm(<trac.perm.PermissionCache object at 0x30e3910>)
2016-10-07 19:21:13,482 Trac[api] DEBUG: Checking permission called with: action(FORM_VIEW),                    username(censored), resource(<Resource u'wiki:PageTemplates/censored, form'>), perm(<trac.perm.PermissionCache object at 0x324e050>)
2016-10-07 19:21:13,484 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 214, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.7/site-packages/trac/wiki/web_ui.py", line 154, in process_request
    return self._do_rename(req, page)
  File "/usr/lib/python2.7/site-packages/trac/wiki/web_ui.py", line 313, in _do_rename
    page.rename(new_name)
  File "/usr/lib/python2.7/site-packages/trac/wiki/model.py", line 197, in rename
    listener.wiki_page_renamed(self, old_name)
  File "build/bdist.linux-x86_64/egg/WikiNotification/listener.py", line 76, in wiki_page_renamed
    wne.notify("renamed", page, author=author, ipnr=ipnr, redirect=redirect, old_name=old_name)
  File "build/bdist.linux-x86_64/egg/WikiNotification/notification.py", line 154, in notify
    NotifyEmail.notify(self, page.name, subject)
  File "/usr/lib/python2.7/site-packages/trac/notification.py", line 344, in notify
    Notify.notify(self, resid)
  File "/usr/lib/python2.7/site-packages/trac/notification.py", line 230, in notify
    (torcpts, ccrcpts) = self.get_recipients(resid)
  File "build/bdist.linux-x86_64/egg/WikiNotification/notification.py", line 171, in get_recipients
    if sid[0] != self.change_author and perm.check_permission(action='WIKI_VIEW', username=sid[0], resource=resource):
  File "/usr/lib/python2.7/site-packages/trac/perm.py", line 462, in check_permission
    perm)
  File "build/bdist.linux-x86_64/egg/privatewiki/api.py", line 44, in check_permission
    return self.check_wiki_access(perm, resource, action, wiki.name)
  File "build/bdist.linux-x86_64/egg/privatewiki/api.py", line 88, in check_wiki_access
    if ('PRIVATE_ALL_VIEW' in perm(res)
TypeError: 'NoneType' object is not callable

I find a very "rough" workaround solution in appending TRAC-ADMIN as a case for access permission but I'm pretty sure it's not the smart fix.

  • privatewiki/api.py

     
    8585                self.env.log.debug('Attempting to protect against %s' % action)
    8686               
    8787                if action == 'WIKI_VIEW':
    88                     if ('PRIVATE_ALL_VIEW' in perm(res)
     88                    if ('PRIVATE_ALL_VIEW' or 'TRAC_ADMIN' in perm(res)
    8989                        or view_perm in perm(res)
    9090                        or edit_perm in perm(res)):
    9191
     
    9393                        return True
    9494
    9595                elif action in ('WIKI_MODIFY', 'WIKI_CREATE'):
    96                     if ('PRIVATE_ALL_EDIT' in perm(res)
     96                    if ('PRIVATE_ALL_EDIT' or 'TRAC_ADMIN' in perm(res)
    9797                        or edit_perm in perm(res)):
    9898
    9999                        self.env.log.debug('--Can MODIFY or CREATE')

Attachments (0)

Change History (4)

comment:1 Changed 8 years ago by Jun Omae

I believe the fix is incorrect. ('PRIVATE_ALL_VIEW' or 'TRAC_ADMIN' in perm(res) ...) is always True.

  • privatewikiplugin/trunk/privatewiki/api.py

    diff --git a/privatewikiplugin/trunk/privatewiki/api.py b/privatewikiplugin/trunk/privatewiki/api.py
    index 920e97b..eda8e47 100644
    a b class PrivateWikiSystem(Component): 
    8585                self.env.log.debug('Attempting to protect against %s' % action)
    8686
    8787                if action == 'WIKI_VIEW':
    88                     if ('PRIVATE_ALL_VIEW' in perm(res)
    89                         or view_perm in perm(res)
    90                         or edit_perm in perm(res)):
     88                    if perm and ('PRIVATE_ALL_VIEW' in perm(res) or
     89                                 view_perm in perm(res) or
     90                                edit_perm in perm(res)):
    9191
    9292                        self.env.log.debug('--Can VIEW')
    9393                        return True
    9494
    9595                elif action in ('WIKI_MODIFY', 'WIKI_CREATE'):
    96                     if ('PRIVATE_ALL_EDIT' in perm(res)
    97                         or edit_perm in perm(res)):
     96                    if perm and ('PRIVATE_ALL_EDIT' in perm(res) or
     97                                edit_perm in perm(res)):
    9898
    9999                        self.env.log.debug('--Can MODIFY or CREATE')
    100100                        return True

comment:2 Changed 8 years ago by Ryan J Ollos

Change looks good to me. Please commit!

comment:3 Changed 8 years ago by Nathan Lewis

Patch has been committed changeset:15906

comment:4 Changed 8 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Nathan Lewis.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.