Commits

mitar committed 1f211c7

Made more robust permission names.

Comments (0)

Files changed (1)

componentpermissions/api.py

     # IPermissionRequestor methods
     
     def _get_permission_name(self, component):
-        return 'COMPONENT_%s_VIEW' % (re.sub('[^a-zA-Z]+', '_', component).strip('_').upper(),)
+        name = re.sub('[^a-zA-Z]+', '_', component).strip('_').upper()
+        if name:
+            return 'COMPONENT_%s_VIEW' % (name,)
+        else:
+            return None
 
     def get_permission_actions(self):
         for component in model.Component.select(self.env):
-            yield self._get_permission_name(component.name)
+            permission = self._get_permission_name(component.name)
+            if permission:
+                yield permission
 
     # IPermissionPolicy methods
 
 
             if should_check_permissions and int(should_check_permissions) and 'component' in ticket.values:
                 permission = self._get_permission_name(ticket['component'])
-                if permission not in perm and 'TICKET_ADMIN' not in perm:
+                if permission and permission not in perm and 'TICKET_ADMIN' not in perm:
                     return False