Module jumpscale.clients.name.name
Expand source code
from jumpscale.clients.base import Client
from jumpscale.core.base import fields
from namecom import Name
from jumpscale.core import events
from jumpscale.core.base.events import AttributeUpdateEvent
class NameClientAttributeUpdated(AttributeUpdateEvent):
    pass
class NameClient(Client):
    username = fields.String()
    token = fields.Secret()
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.__client = None
    def _attr_updated(self, name, value):
        super()._attr_updated(name, value)
        # this will allow other people to listen to this event too
        event = NameClientAttributeUpdated(self, name, value)
        events.notify(event)
        # reset client
        self.__client = None
    @property
    def nameclient(self):
        if not self.__client:
            self.__client = Name(self.username, self.token)
        return self.__client
Classes
class NameClient (*args, **kwargs)- 
A simple attribute-based namespace.
SimpleNamespace(**kwargs)
base class implementation for any class with fields which supports getting/setting raw data for any instance fields.
any instance can have an optional name and a parent.
class Person(Base): name = fields.String() age = fields.Float() p = Person(name="ahmed", age="19") print(p.name, p.age)Args
parent_:Base, optional- parent instance. Defaults to None.
 instance_name_:str, optional- instance name. Defaults to None.
 **values- any given field values to initiate the instance with
 
Expand source code
class NameClient(Client): username = fields.String() token = fields.Secret() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.__client = None def _attr_updated(self, name, value): super()._attr_updated(name, value) # this will allow other people to listen to this event too event = NameClientAttributeUpdated(self, name, value) events.notify(event) # reset client self.__client = None @property def nameclient(self): if not self.__client: self.__client = Name(self.username, self.token) return self.__clientAncestors
Instance variables
var nameclient- 
Expand source code
@property def nameclient(self): if not self.__client: self.__client = Name(self.username, self.token) return self.__client var token- 
getter method this property
will call
_get_value, which would if the value is already defined and will get the default value if notReturns
any- the field value
 
Expand source code
def getter(self): """ getter method this property will call `_get_value`, which would if the value is already defined and will get the default value if not Returns: any: the field value """ return self._get_value(name, field) var username- 
getter method this property
will call
_get_value, which would if the value is already defined and will get the default value if notReturns
any- the field value
 
Expand source code
def getter(self): """ getter method this property will call `_get_value`, which would if the value is already defined and will get the default value if not Returns: any: the field value """ return self._get_value(name, field) 
Inherited members
 class NameClientAttributeUpdated (instance, name, new_value)- 
Expand source code
class NameClientAttributeUpdated(AttributeUpdateEvent): passAncestors