Code Duplication    Length = 11-14 lines in 2 locations

bika/lims/browser/analysisrequest/add2.py 1 location

@@ 824-837 (lines=14) @@
821
        self.traverse_subpath.append(name)
822
        return self
823
824
    @returns_json
825
    def __call__(self):
826
        """Dispatch the path to a method and return JSON.
827
        """
828
        protect.CheckAuthenticator(self.request.form)
829
        protect.PostOnly(self.request.form)
830
831
        if len(self.traverse_subpath) != 1:
832
            return self.error("Not found", status=404)
833
        func_name = "ajax_{}".format(self.traverse_subpath[0])
834
        func = getattr(self, func_name, None)
835
        if func is None:
836
            return self.error("Invalid function", status=400)
837
        return func()
838
839
    def error(self, message, status=500, **kw):
840
        """Set a JSON error object and a status to the response

bika/lims/browser/attachment.py 1 location

@@ 532-542 (lines=11) @@
529
    def __init__(self, context, request):
530
        super(ajaxAttachmentsView, self).__init__(context, request)
531
532
    @returns_json
533
    def __call__(self):
534
        protect.CheckAuthenticator(self.request.form)
535
536
        if len(self.traverse_subpath) != 1:
537
            return self.error("Not found", status=404)
538
        func_name = "ajax_{}".format(self.traverse_subpath[0])
539
        func = getattr(self, func_name, None)
540
        if func is None:
541
            return self.error("Invalid function", status=400)
542
        return func()
543
544
    def error(self, message, status=500, **kw):
545
        self.request.response.setStatus(status)