Beispiel #1
0
    def _update(self, service, root, child=None, xa=None):
        etag = root.k2resp.headers['etag']
        root_type = root.__class__.__name__
        root_id = root.id

        child_type = None
        child_id = None
        if child is not None:
            etag = child.k2resp.headers['etag']
            element_type = type(child)
            child_type = child.__class__.__name__
            child_id = child.id
            element = v1k2creater.process_root(service,
                                               v1k2creater.Mode.UPDATE,
                                               child)
        else:
            element_type = type(root)
            element = v1k2creater.process_root(service,
                                               v1k2creater.Mode.UPDATE,
                                               root)
        k2resp = self.api.client.update(service,
                                        etag,
                                        element,
                                        root_type,
                                        root_id,
                                        child_type=child_type,
                                        child_id=child_id,
                                        xa=xa)

        obj_class = element_type
#         print "Updated: child_type: >%s<, child_id: >%s" % (child_type,
#                                                             child_id)
        obj = obj_class().loadAsRoot(self, k2resp.entry, k2resp, True)
        return obj
Beispiel #2
0
    def _create(self, service, root, child=None, xa=None):
        root_type = root.__class__.__name__

        root_id = None
        child_type = None
        if child is not None:
            element_type = type(child)
            root_id = root.id
            child_type = child.__class__.__name__
            element = v1k2creater.process_root(service,
                                               v1k2creater.Mode.CREATE,
                                               child)
        else:
            element_type = type(root)
            element = v1k2creater.process_root(service,
                                               v1k2creater.Mode.CREATE,
                                               root)

        k2resp = self.api.client.create(service,
                                        element,
                                        root_type,
                                        root_id=root_id,
                                        child_type=child_type,
                                        xa=xa)
        obj_class = element_type
        obj = obj_class().loadAsRoot(self, k2resp.entry, k2resp, True)
        return obj
Beispiel #3
0
 def _runjob(self, root, child, xa=None):
     service = "web"
     root_type = root.__class__.__name__
     root_id = root.id
     element = v1k2creater.process_root(service,
                                        v1k2creater.Mode.UPDATE,
                                        child)
     k2resp = self.api.client.runjob(element,
                                     root_type,
                                     root_id=root_id,
                                     xa=xa)
     obj = k2web.JobResponse()
     v1k2loader.process_root("web", obj, k2resp.entry.element)
     obj._k2resp = k2resp
     return obj