Exemplo n.º 1
0
 def set_property(self, name, value, serializable=True):
     super(Folder, self).set_property(name, value, serializable)
     # fallback: create a new resource path
     if self._resource_path is None:
         if name == "ServerRelativeUrl":
             self._resource_path = ResourcePathEntity(
                 self.context,
                 ResourcePathEntity.from_uri("Web", self.context),
                 ODataPathParser.from_method("GetFolderByServerRelativeUrl",
                                             [value]))
         elif name == "UniqueId":
             self._resource_path = ResourcePathEntity(
                 self.context,
                 ResourcePathEntity.from_uri("Web", self.context),
                 ODataPathParser.from_method("GetFolderById", [value]))
Exemplo n.º 2
0
    def resource_path(self):
        resource_path = super(Folder, self).resource_path
        if resource_path:
            return resource_path

        # fallback: create a new resource path
        if self.is_property_available("ServerRelativeUrl"):
            self._resource_path = ResourcePathEntity(
                self.context, ResourcePathEntity.from_uri("Web", self.context),
                ODataPathParser.from_method(
                    "GetFolderByServerRelativeUrl",
                    [self.properties["ServerRelativeUrl"]]))
        elif self.is_property_available("UniqueId"):
            self._resource_path = ResourcePathEntity(
                self.context, ResourcePathEntity.from_uri("Web", self.context),
                ODataPathParser.from_method(
                    "GetFolderById", [{
                        'guid': self.properties["UniqueId"]
                    }]))
        return self._resource_path
Exemplo n.º 3
0
    def create_typed_object(self, properties, client_object_type):
        from office365.sharepoint.client_context import ClientContext
        from office365.runtime.resource_path_entity import ResourcePathEntity

        if client_object_type is None:
            raise AttributeError("No class for object type '{0}' found".format(
                client_object_type))

        web_url, resource_path = properties["__metadata"]["uri"].split(
            "/_api/")

        context = self.context
        if client_object_type.__name__ == "Web":
            # create a new context to represent the new web object
            context = ClientContext(web_url, self.context.auth_context)

        client_object = client_object_type(
            context, ResourcePathEntity.from_uri(resource_path, self.context))
        client_object._parent_collection = self
        client_object.map_json(properties)

        return client_object