Beispiel #1
0
    def is_enable_logging(self):
        """ `True` if `logging` is enabled. """
        #TODO: -------------------[remove in v1.2.0]------------------------
        deprecation('the is_enabled_logging method will be removed in version 1.2.0, use the logging and log_level properties instead!')
        #TODO: -------------------[remove in v1.2.0]------------------------

        return (self.log.level == logging.DEBUG)
Beispiel #2
0
    def full(self, direct_only = False, **kwargs):
        """ Enable eager-loading of resource attributes.

        With this modifier, resources will have their attributes
        already loaded.
        
        If ``only_direct`` is set to `True`, only direct attributes
        will be loaded. Accessing inverse attributes will work
        but will generate extra requests to triple store.

        Whether setting this will bring performance
        improvements depends on reader plugin implementation.
        For example, sparql_protocol plugin is capable of using SPARQL
        subqueries to fully load multiple resources in one request.

         """

        #TODO: -------------------[remove in v1.2.0]------------------------
        if 'only_direct' in kwargs:
            deprecation('the only_direct argument is deprecated and will be removed in version 1.2.0, use direct_only instead!')
            direct_only = kwargs['only_direct']
        #TODO: -------------------[remove in v1.2.0]------------------------

        params                  = self.__params.copy()
        params['full']          = True
        params['direct_only']   = direct_only
        return ResultProxy(params)
Beispiel #3
0
    def load(self, direct_only=False, **kwargs):
        """Load all attributes from the data store.
        
        By default, load all attributes from the data store:
            - direct attributes (where the subject is the subject of the resource)
            - indirect attributes (where the object is the subject of the resource)

        If `direct_only` is `False`, don't load inverse attributes (incoming arcs).
        This can be used as optimization when client knows invese
        attributes won't be accessed. 

        .. note:: This method resets the *dirty* state of the object.

        """

        results_d = self.session[self.store_key].load(self, True)
        self.__set_predicate_values(results_d, True)
        self.__full_direct = True

        #TODO: -------------------[remove in v1.2.0]------------------------
        if 'only_direct' in kwargs:
            deprecation('the only_direct argument is deprecated and will be removed in version 1.2.0, use direct_only instead!')
            direct_only = kwargs['only_direct']
        #TODO: -------------------[remove in v1.2.0]------------------------
        if not direct_only:
            results_i = self.session[self.store_key].load(self, False)
            self.__set_predicate_values(results_i, False)
            self.__full_inverse = True

        self.dirty = False
Beispiel #4
0
    def full(self, direct_only=False, **kwargs):
        """ Enable eager-loading of resource attributes.

        With this modifier, resources will have their attributes
        already loaded.
        
        If ``only_direct`` is set to `True`, only direct attributes
        will be loaded. Accessing inverse attributes will work
        but will generate extra requests to triple store.

        Whether setting this will bring performance
        improvements depends on reader plugin implementation.
        For example, sparql_protocol plugin is capable of using SPARQL
        subqueries to fully load multiple resources in one request.

         """

        #TODO: -------------------[remove in v1.2.0]------------------------
        if 'only_direct' in kwargs:
            deprecation(
                'the only_direct argument is deprecated and will be removed in version 1.2.0, use direct_only instead!'
            )
            direct_only = kwargs['only_direct']
        #TODO: -------------------[remove in v1.2.0]------------------------

        params = self.__params.copy()
        params['full'] = True
        params['direct_only'] = direct_only
        return ResultProxy(params)
Beispiel #5
0
    def load(self, direct_only=False, **kwargs):
        """Load all attributes from the data store.
        
        By default, load all attributes from the data store:
            - direct attributes (where the subject is the subject of the resource)
            - indirect attributes (where the object is the subject of the resource)

        If `direct_only` is `False`, don't load inverse attributes (incoming arcs).
        This can be used as optimization when client knows invese
        attributes won't be accessed. 

        .. note:: This method resets the *dirty* state of the object.

        """

        results_d = self.session[self.store_key].load(self, True)
        self.__set_predicate_values(results_d, True)
        self.__full_direct = True

        #TODO: -------------------[remove in v1.2.0]------------------------
        if 'only_direct' in kwargs:
            deprecation(
                'the only_direct argument is deprecated and will be removed in version 1.2.0, use direct_only instead!'
            )
            direct_only = kwargs['only_direct']
        #TODO: -------------------[remove in v1.2.0]------------------------
        if not direct_only:
            results_i = self.session[self.store_key].load(self, False)
            self.__set_predicate_values(results_i, False)
            self.__full_inverse = True

        self.dirty = False
Beispiel #6
0
    def enable_logging(self, enable = True):
        """ Enables or disable `logging` for the current `plugin`. """
        #TODO: -------------------[remove in v1.2.0]------------------------
        deprecation('the enable_logging method will be removed in version 1.2.0, use the logging and log_level properties instead!')
        #TODO: -------------------[remove in v1.2.0]------------------------

        level = enable and logging.DEBUG or logging.NOTSET
        self.log.setLevel(level)
Beispiel #7
0
    def is_enable_logging(self):
        """ `True` if `logging` is enabled. """
        #TODO: -------------------[remove in v1.2.0]------------------------
        deprecation(
            'the is_enabled_logging method will be removed in version 1.2.0, use the logging and log_level properties instead!'
        )
        #TODO: -------------------[remove in v1.2.0]------------------------

        return (self.log.level == logging.DEBUG)
Beispiel #8
0
 def full(self, direct_only = False, **kwargs):
     ''' get the `full` `query` attribute. Syntactic sugar
     for :meth:`surf.resource.Resource.query_attribute` method.
     '''
     #TODO: -------------------[remove in v1.2.0]------------------------
     if 'only_direct' in kwargs:
         deprecation('the only_direct argument is deprecated and will be removed in version 1.2.0, use direct_only instead!')
         direct_only = kwargs['only_direct']
     #TODO: -------------------[remove in v1.2.0]------------------------
     return self.__query_attribute().full(direct_only)
Beispiel #9
0
    def enable_logging(self, enable=True):
        """ Enables or disable `logging` for the current `plugin`. """
        #TODO: -------------------[remove in v1.2.0]------------------------
        deprecation(
            'the enable_logging method will be removed in version 1.2.0, use the logging and log_level properties instead!'
        )
        #TODO: -------------------[remove in v1.2.0]------------------------

        level = enable and logging.DEBUG or logging.NOTSET
        self.log.setLevel(level)