AccessControlMixin doesn't work with models defined in plugins
Xarthisius opened this issue · comments
Description
AccessControlMixin
uses ModelImporter.load
to load a proper model class throughout its methods. The signature of the latter is:
girder/girder/utility/model_importer.py
Line 37 in dc40cd6
However, almost all invocation of ModelImporter.load
in AccessControlMixin
simply pass a single argument self.resourceColl
. The only place where the additional plugin
kwarg is handled is here:
girder/girder/utility/acl_mixin.py
Lines 56 to 57 in dc40cd6
Expected results
Handle models defined in plugins, e.g.:
# server/models/form.py
class Form(AccessControlledModel):
def initialize(self):
self.name = "form"
# server/models/entry.py
class FormEntry(acl_mixin.AccessControlMixin, Model):
def initialize(self):
self.name = "entry"
self.ensureIndices(["formId", "data.sampleId"])
self.resourceColl = ("form", "jsonforms")
self.resourceParent = "formId"
Actual results
Traceback (most recent call last):
File "/girder/girder/api/rest.py", line 630, in endpointDecorator
val = fun(self, path, params)
File "/girder/girder/api/rest.py", line 1216, in GET
return self.handleRoute('GET', path, params)
File "/girder/girder/api/rest.py", line 970, in handleRoute
val = handler(**kwargs)
File "/girder/girder/api/describe.py", line 709, in wrapped
return fun(*args, **kwargs)
File "/girder/girder/api/rest.py", line 445, in wrapped
val = fun(*args, **kwargs)
File "/girder/plugins/jsonforms/server/rest/entry.py", line 38, in listFormEntry
cursor = FormEntryModel().findWithPermissions(
File "/girder/girder/utility/acl_mixin.py", line 303, in findWithPermissions
if (not isinstance(self.model(self.resourceColl), AccessControlledModel) or
File "/girder/girder/utility/model_importer.py", line 88, in model
module = 'girder.models.%s' % model
One solution would be to add a special attribute to AccessControlMixin
called model_name: str
, and if present, would override the default behavior.
Or else it could be called acl_proxy_model
and it could be set to a model class.