Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support context aware report controller views #88

Merged
merged 3 commits into from
Mar 6, 2020

Conversation

ramonski
Copy link
Contributor

@ramonski ramonski commented Mar 5, 2020

Description of the issue/feature this PR addresses

At the moment the report controller view is a multi-adapter for model/collection and the request.
The rendering context within the view (self.context) is hard coded to the portal object.

This PR allows to register a context aware multi-adapter for the current rendering context, the model/collection and the request.

The registration in configure.zcml can be done like this:

  <!-- View for Single Reports -->
  <adapter
      for="*
           *
           my.lims.interfaces.IMyLIMS"
      name="AnalysisRequest"
      factory=".reportview.MySingleReportView"
      provides="senaite.impress.interfaces.IReportView"
      permission="zope2.View"/>

  <!-- View for Multi Reports -->
  <adapter
      for="*
           *
           my.lims.interfaces.IMyLIMSLayer"
      name="AnalysisRequest"
      factory=".reportview.MyMultiReportView"
      provides="senaite.impress.interfaces.IMultiReportView"
      permission="zope2.View"/>

With this corresponding report controller view implementation:

from senaite.impress.analysisrequest.reportview import MultiReportView

class MyMultiReportView(MultiReportView):
    """My specific controller view for multi-reports
    """

    def __init__(self, context, collection, request):
        logger.info("MyMultiReportView::__init__:collection={}"
                    .format(collection))
        super(MultiReportView, self).__init__(collection, request)
        self.collection = collection
        self.context = context
        self.request = request

Any context aware multi-adapter takes precedence over the multi-adapters that only adapt the model/controller and the request

Current behavior before PR

No context aware report controller views supported

Desired behavior after PR is merged

Context aware report controller views supported

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@ramonski ramonski requested a review from xispa March 5, 2020 13:01
@xispa xispa merged commit 1bf4ca6 into master Mar 6, 2020
@xispa xispa deleted the context-aware-report-controller-view branch March 6, 2020 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants