예제 #1
0
    def get_resource(self,
                     subject,
                     uri=None,
                     store=None,
                     graph=None,
                     block_auto_load=False,
                     context=None,
                     query_contexts=None,
                     *classes):
        """ Same as `map_type` but `set` the resource from the `graph`. """

        if not isinstance(subject, URIRef):
            subject = URIRef(unicode(subject))

        if uri is None:
            uri = Resource.concept(subject)

        resource = self.map_instance(uri,
                                     subject,
                                     store,
                                     classes,
                                     block_auto_load=block_auto_load,
                                     context=context,
                                     query_contexts=query_contexts)

        if graph:
            resource.set(graph)

        return resource
예제 #2
0
    def commit(self):
        """ Commits all changes. In essence the method updates all the `dirty`
        registered `resources`. """

        # Copy set into list because it will shrink as we go through it
        for resource in list(Resource.get_dirty_instances()):
            resource.update()
예제 #3
0
    def get_resource(self,
                     subject,
                     concept=None,
                     store=None,
                     graph=None,
                     block_auto_load=False,
                     context=None,
                     classes=None):
        """ Same as `map_type` but `set` the resource from the `graph`. """

        classes = classes if isinstance(classes, (tuple, set, list)) else []

        if not isinstance(subject, URIRef):
            subject = URIRef(str(subject))

        if concept is None:
            concept = Resource.concept(subject)

        resource = self.map_instance(concept,
                                     subject,
                                     store=store,
                                     classes=classes,
                                     block_auto_load=block_auto_load,
                                     context=context)

        if graph:
            resource.set(graph)

        return resource
예제 #4
0
    def commit(self):
        """ Commits all changes. In essence the method updates all the `dirty`
        registered `resources`. """

        # Copy set into list because it will shrink as we go through it
        for resource in list(Resource.get_dirty_instances()):
            resource.update()
예제 #5
0
파일: session.py 프로젝트: tatiana/surf
    def get_resource(self, subject, uri = None, store = None, graph = None,
                     block_auto_load = False, context = None, *classes):
        """ Same as `map_type` but `set` the resource from the `graph`. """

        if not isinstance(subject, URIRef):
            subject = URIRef(unicode(subject))

        if uri is None:
            uri = Resource.concept(subject)

        resource = self.map_instance(uri, subject, store, classes,
                                     block_auto_load = block_auto_load,
                                     context = context)

        if graph:
            resource.set(graph)

        return resource
예제 #6
0
    def get_resource(self, subject, concept = None, store = None, graph = None,
                     block_auto_load = False, context = None, classes = None):
        """ Same as `map_type` but `set` the resource from the `graph`. """

        classes = classes if isinstance(classes, (tuple, set, list)) else []

        if not isinstance(subject, URIRef):
            subject = URIRef(unicode(subject))

        if concept is None:
            concept = Resource.concept(subject)

        resource = self.map_instance(concept, subject, store = store, classes = classes,
                                     block_auto_load = block_auto_load,
                                     context = context )

        if graph:
            resource.set(graph)

        return resource
예제 #7
0
파일: session.py 프로젝트: tatiana/surf
    def commit(self):
        """ Commit all the changes, update all the `dirty` `resources`. """

        # Copy set into list because it will shrink as we go through it
        for resource in list(Resource.get_dirty_instances()):
            resource.update()
예제 #8
0
    def commit(self):
        """ Commit all the changes, update all the `dirty` `resources`. """

        # Copy set into list because it will shrink as we go through it
        for resource in list(Resource.get_dirty_instances()):
            resource.update()