Пример #1
0
 def POST(self):
     orphans = self.params()
     orphan_manager = factory.content_orphan_manager()
     tags = [action_tag('delete_orphans'),
             resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')]
     call_request = CallRequest(orphan_manager.delete_orphans_by_id, [orphans], tags=tags, archive=True)
     return execution.execute_async(self, call_request)
Пример #2
0
 def DELETE(self, content_type, content_id):
     orphan_manager = factory.content_orphan_manager()
     orphan_manager.get_orphan(content_type, content_id)
     ids = [{'content_type_id': content_type, 'unit_id': content_id}]
     tags = [resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')]
     call_request = CallRequest(orphan_manager.delete_orphans_by_id, [ids], tags=tags, archive=True)
     return execution.execute_async(self, call_request)
Пример #3
0
 def clean_orphans(self):
     """
     Exposes the ability to clean up this unit as an orphan.
     """
     orphan_manger = factory.content_orphan_manager()
     orphan_manger.delete_orphan_content_units_by_type(
         self._content_type_id, self.id)
Пример #4
0
 def GET(self, content_type):
     orphan_manager = factory.content_orphan_manager()
     # NOTE this can still potentially stomp on memory, but hopefully the
     # _with_unit_keys methods will reduce the foot print enough that
     # we'll never see this bug again
     orphans = list(orphan_manager.generate_orphans_by_type_with_unit_keys(content_type))
     map(lambda o: o.update(serialization.link.child_link_obj(o['_id'])), orphans)
     return self.ok(orphans)
Пример #5
0
 def GET(self, content_type):
     orphan_manager = factory.content_orphan_manager()
     # NOTE this can still potentially stomp on memory, but hopefully the
     # _with_unit_keys methods will reduce the foot print enough that
     # we'll never see this bug again
     orphans = list(orphan_manager.generate_orphans_by_type_with_unit_keys(content_type))
     map(lambda o: o.update(serialization.link.child_link_obj(o['_id'])), orphans)
     return self.ok(orphans)
Пример #6
0
 def GET(self):
     orphan_manager = factory.content_orphan_manager()
     summary = orphan_manager.orphans_summary()
     # convert the counts into sub-documents so we can add _href fields to them
     rest_summary = dict((k, {'count': v}) for k, v in summary.items())
     # add links to the content type sub-collections
     map(lambda k: rest_summary[k].update(serialization.link.child_link_obj(k)), rest_summary)
     return self.ok(rest_summary)
Пример #7
0
 def GET(self):
     orphan_manager = factory.content_orphan_manager()
     summary = orphan_manager.orphans_summary()
     # convert the counts into sub-documents so we can add _href fields to them
     rest_summary = dict((k, {'count': v}) for k, v in summary.items())
     # add links to the content type sub-collections
     map(lambda k: rest_summary[k].update(serialization.link.child_link_obj(k)), rest_summary)
     return self.ok(rest_summary)
Пример #8
0
 def DELETE(self):
     orphan_manager = factory.content_orphan_manager()
     tags = [
         resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE,
                      'orphans')
     ]
     call_request = CallRequest(orphan_manager.delete_all_orphans,
                                tags=tags,
                                archive=True)
     return execution.execute_async(self, call_request)
Пример #9
0
 def DELETE(self, content_type, content_id):
     orphan_manager = factory.content_orphan_manager()
     orphan_manager.get_orphan(content_type, content_id)
     ids = [{'content_type_id': content_type, 'unit_id': content_id}]
     tags = [
         resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE,
                      'orphans')
     ]
     call_request = CallRequest(orphan_manager.delete_orphans_by_id, [ids],
                                tags=tags,
                                archive=True)
     return execution.execute_async(self, call_request)
Пример #10
0
 def POST(self):
     orphans = self.params()
     orphan_manager = factory.content_orphan_manager()
     tags = [
         action_tag('delete_orphans'),
         resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE,
                      'orphans')
     ]
     call_request = CallRequest(orphan_manager.delete_orphans_by_id,
                                [orphans],
                                tags=tags,
                                archive=True)
     return execution.execute_async(self, call_request)
Пример #11
0
    def delete(self, request, content_type):
        """
        Dispatch a delete_orphans_by_type task.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: restrict the list of orphans to be deleted to this content type
        :type  content_type: str

        :raises: OperationPostponed when an async operation is performed
        """
        orphan_manager = factory.content_orphan_manager()
        orphan_manager.validate_type(content_type)
        task_tags = [tags.resource_tag(tags.RESOURCE_CONTENT_UNIT_TYPE, "orphans")]
        async_task = content_orphan.delete_orphans_by_type.apply_async((content_type,), tags=task_tags)
        raise OperationPostponed(async_task)
Пример #12
0
    def get(self, request, content_type, unit_id):
        """
        Return a serialized object representing the requested orphan

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: content type of the requested orphan
        :type  content_type: str
        :param unit_id: id of the requested unit
        :type  unit_id: str

        :return: response conainting a serialized dict of the requested orphan
        :rtype : django.http.HttpResponse
        """
        orphan_manager = factory.content_orphan_manager()
        orphan_dict = orphan_manager.get_orphan(content_type, unit_id)
        orphan_dict['_href'] = request.get_full_path()
        return generate_json_response(orphan_dict)
Пример #13
0
    def get(self, request, content_type, unit_id):
        """
        Return a serialized object representing the requested orphan

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: content type of the requested orphan
        :type  content_type: str
        :param unit_id: id of the requested unit
        :type  unit_id: str

        :return: response conainting a serialized dict of the requested orphan
        :rtype : django.http.HttpResponse
        """
        orphan_manager = factory.content_orphan_manager()
        orphan_dict = orphan_manager.get_orphan(content_type, unit_id)
        orphan_dict["_href"] = request.get_full_path()
        return generate_json_response(orphan_dict)
Пример #14
0
    def delete(self, request, content_type):
        """
        Dispatch a delete_orphans_by_type task.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: restrict the list of orphans to be deleted to this content type
        :type  content_type: str

        :raises: OperationPostponed when an async operation is performed
        """
        orphan_manager = factory.content_orphan_manager()
        orphan_manager.validate_type(content_type)
        task_tags = [
            tags.resource_tag(tags.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')
        ]
        async_task = content_orphan.delete_orphans_by_type.apply_async(
            (content_type, ), tags=task_tags)
        raise OperationPostponed(async_task)
Пример #15
0
    def get(self, request, content_type):
        """
        Returns a response containing a serialized list of all orphans of the specified type.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: restrict the list of orphans to this content type
        :type  content_type: str

        :return: response containing a serialized list of all orphans of specified type.
        :rtype : django.http.HttpResponse
        """
        orphan_manager = factory.content_orphan_manager()
        matched_orphans = list(orphan_manager.generate_orphans_by_type_with_unit_keys(content_type))
        for orphan_dict in matched_orphans:
            orphan_dict["_href"] = reverse(
                "content_orphan_resource", kwargs={"content_type": content_type, "unit_id": orphan_dict["_id"]}
            )
        return generate_json_response(matched_orphans)
Пример #16
0
    def delete(self, request, content_type, unit_id):
        """
        Dispatch a delete_orphans_by_id task.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: content type of the requested orphan
        :type  content_type: str
        :param unit_id: id of the requested orphan
        :type  unit_id: str

        :raises: OperationPostponed when an async operation is performed
        """
        orphan_manager = factory.content_orphan_manager()
        orphan_manager.get_orphan(content_type, unit_id)
        unit_info = [{"content_type_id": content_type, "unit_id": unit_id}]
        task_tags = [tags.resource_tag(tags.RESOURCE_CONTENT_UNIT_TYPE, "orphans")]
        async_task = content_orphan.delete_orphans_by_id.apply_async((unit_info,), tags=task_tags)
        raise OperationPostponed(async_task)
Пример #17
0
    def get(self, request):
        """
        Return a response containing a dict of dicts, one for each orphaned unit.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest

        :return: response containing a dict that itself contains a dict for each orphan.
        :rtype: django.http.HttpResponse
        """
        orphan_manager = factory.content_orphan_manager()

        # convert the counts into sub-documents so we can add _href fields to them
        # add links to the content type sub-collections
        rest_summary = {}
        for key, value in orphan_manager.orphans_summary().items():
            rest_summary[key] = {
                "count": value,
                "_href": reverse("content_orphan_type_subcollection", kwargs={"content_type": key}),
            }
        return generate_json_response(rest_summary)
Пример #18
0
    def delete(self, request, content_type, unit_id):
        """
        Dispatch a delete_orphans_by_id task.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: content type of the requested orphan
        :type  content_type: str
        :param unit_id: id of the requested orphan
        :type  unit_id: str

        :raises: OperationPostponed when an async operation is performed
        """
        orphan_manager = factory.content_orphan_manager()
        orphan_manager.get_orphan(content_type, unit_id)
        unit_info = [{'content_type_id': content_type, 'unit_id': unit_id}]
        task_tags = [
            tags.resource_tag(tags.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')
        ]
        async_task = content_orphan.delete_orphans_by_id.apply_async(
            (unit_info, ), tags=task_tags)
        raise OperationPostponed(async_task)
Пример #19
0
    def get(self, request, content_type):
        """
        Returns a response containing a serialized list of all orphans of the specified type.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param content_type: restrict the list of orphans to this content type
        :type  content_type: str

        :return: response containing a serialized list of all orphans of specified type.
        :rtype : django.http.HttpResponse
        """
        orphan_manager = factory.content_orphan_manager()
        matched_orphans = list(
            orphan_manager.generate_orphans_by_type_with_unit_keys(
                content_type))
        for orphan_dict in matched_orphans:
            orphan_dict['_href'] = reverse('content_orphan_resource',
                                           kwargs={
                                               'content_type': content_type,
                                               'unit_id': orphan_dict['_id']
                                           })
        return generate_json_response(matched_orphans)
Пример #20
0
    def get(self, request):
        """
        Return a response containing a dict of dicts, one for each orphaned unit.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest

        :return: response containing a dict that itself contains a dict for each orphan.
        :rtype: django.http.HttpResponse
        """
        orphan_manager = factory.content_orphan_manager()

        # convert the counts into sub-documents so we can add _href fields to them
        # add links to the content type sub-collections
        rest_summary = {}
        for key, value in orphan_manager.orphans_summary().items():
            rest_summary[key] = {
                'count':
                value,
                '_href':
                reverse('content_orphan_type_subcollection',
                        kwargs={'content_type': key})
            }
        return generate_json_response(rest_summary)
Пример #21
0
 def GET(self, content_type, content_id):
     orphan_manager = factory.content_orphan_manager()
     orphan = orphan_manager.get_orphan(content_type, content_id)
     orphan.update(serialization.link.current_link_obj())
     return self.ok(orphan)
Пример #22
0
 def clean_orphans(self):
     """
     Exposes the ability to clean up this unit as an orphan.
     """
     orphan_manger = factory.content_orphan_manager()
     orphan_manger.delete_orphan_content_units_by_type(self._content_type_id, self.id)
Пример #23
0
 def test_factory(self):
     try:
         manager_factory.content_orphan_manager()
     except:
         self.fail(traceback.format_exc())
Пример #24
0
 def test_factory(self):
     try:
         manager_factory.content_orphan_manager()
     except:
         self.fail(traceback.format_exc())
Пример #25
0
 def GET(self, content_type, content_id):
     orphan_manager = factory.content_orphan_manager()
     orphan = orphan_manager.get_orphan(content_type, content_id)
     orphan.update(serialization.link.current_link_obj())
     return self.ok(orphan)
Пример #26
0
 def DELETE(self, content_type):
     orphan_manager = factory.content_orphan_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, 'orphans')]
     call_request = CallRequest(orphan_manager.delete_orphans_by_type, [content_type], tags=tags, archive=True)
     return execution.execute_async(self, call_request)
Пример #27
0
 def GET(self, content_type):
     orphan_manager = factory.content_orphan_manager()
     orphans = orphan_manager.list_orphans_by_type(content_type)
     map(lambda o: o.update(serialization.link.child_link_obj(o['_id'])), orphans)
     return self.ok(orphans)