Refetch instance data from the API.
9092
def refresh(self):
      '''
      '''
      response = requests.get('%s/categories/%s' % (API_BASE_URL, self.name))
      attributes = response.json()
      
      self.ancestors = [Category(name) for name in attributes['ancestors']]
      self.contents = WikiText(attributes['contents_raw'],
                               attributes['contents_rendered'])
      self.description = attributes['description']
      self.guides = []
      for guide in attributes['guides']:
         self.guides.append(Guide(guide['guideid']))
      # Unlike guides, categories return flags as a dict, keyed by flagid.
      # *Except* when it's empty, in which case we get an empty list due to
      # PHP's json_encode() not knowing the difference between an empty array
      # and an empty dict.
      flags = dict(attributes['flags']).values()
      self.flags = [Flag.from_id(flag['flagid']) for flag in flags]
      self.image = Image(attributes['image']['id']) if attributes['image'] else None
      self.locale = attributes['locale']
      #self.parts = attributes['parts']
      #self.solutions = attributes['solutions']
      self.title = attributes['display_title']
1353318
def _update(self, data):
        """"""
        for k, v in six.iteritems(data):
            new_value = v
            if isinstance(v, dict):
                new_value = type(self)(v)
            elif isinstance(v, list):
                new_value = [(type(self)(e) if isinstance(e, dict) else e)
                             for e in v]
            setattr(self, k, new_value)
636988
def refresh(self, fields=None, **kwargs):
        
        cond = self.c[self._primary_field]==self._key
        query = self.filter(cond, **kwargs)
        if not fields:
            fields = list(self.table.c)
        
        v = query.values_one(*fields)
        if not v:
            raise NotFound('Instance <{0}:{1}> can not be found'.format(self.tablename, self._key))
        
        d = self._data_prepare(v.items())
        self.update(**d)
        self.set_saved()
1279202
def _update_api_client(self, api_parent_class=None):
        """"""
        clients = ([self.api_clients[api_parent_class]]
                   if api_parent_class else self.api_clients.values())

        for api_client in clients:
            api_client.configuration.host = (self.config.get('host') or
                                             api_client.configuration.host)
            api_client.configuration.api_key['Authorization'] = self.config['api_key']
876067
def update(self, data):
        
        if not data:
            return
        _rk, _dumps = self.get_key, self._dumps
        data = self._client.mset({
            _rk(key): _dumps(value)
            for key, value in data.items()})
1131998
def instantiate_references_json(references_json):
    ''' 

    '''

    # Create all instances, but without setting their props
    references = {}
    for obj in references_json:
        obj_id = obj['id']
        obj_type = obj.get('subtype', obj['type'])

        cls = get_class(obj_type)
        instance = cls.__new__(cls, id=obj_id)
        if instance is None:
            raise RuntimeError('Error loading model from JSON (type: %s, id: %s)' % (obj_type, obj_id))
        references[instance.id] = instance

    return references
1121991
def modify(self, **params):
        """"""
        data = self.api_client.update_current_user(**params)
        self.update(data)
        return data
1297785
def reload(self):
        
        try:
            data = self._api.get(self.href, append_base=False).json()
            resource = File(api=self._api, **data)
        except Exception:
            try:
                data = self._api.get(
                    self._URL['get'].format(id=self.id)).json()
                resource = File(api=self._api, **data)
            except Exception:
                raise SbgError('Resource can not be refreshed!')

        self._data = resource._data
        self._dirty = resource._dirty
        self._old = copy.deepcopy(self._data.data)

        # If file.metadata = value was executed
        # file object will have attribute _method='PUT', which tells us
        # to force overwrite of metadata on the server. This is metadata
        # specific. Once we reload the resource we delete the attribute
        # _method from the instance.
        try:
            delattr(self, '_method')
        except AttributeError:
            pass
252978
def fixup_instance(sender, **kwargs):
    
    instance = kwargs['instance']
    for model_field in instance._meta.fields:

        if not isinstance(model_field, JSONAttributeField):
            continue

        if hasattr(instance, '_attr_field'):
            raise FieldError('multiple JSONAttributeField fields: '
                             'only one is allowed per model!')

        field_name = model_field.name
        attrs = getattr(instance, field_name)

        # ensure JSONAttributeField's data is of JSONAttributes type
        if not isinstance(attrs, JSONAttributes):
            setattr(instance, field_name, JSONAttributes(attrs))
            attrs = getattr(instance, field_name)

        # Cache model instance on JSONAttributes instance and vice-versa
        attrs._instance = instance
        attrs._get_from_instance = functools.partial(
            getattr, instance, field_name)
        instance._attr_field = attrs

    if not hasattr(instance, '_attr_field'):
        raise FieldError('missing JSONAttributeField field in '
                         'fixup_instance decorator')
300821
def reload(self, *fields, **kw):
		""""""
		
		Doc, collection, query, options = self._prepare_find(id=self.id, projection=fields, **kw)
		result = collection.find_one(query, **options)
		
		if fields:  # Refresh only the requested data.
			for k in result:  # TODO: Better merge algorithm.
				if k == ~Doc.id: continue
				self.__data__[k] = result[k]
		else:
			self.__data__ = result
		
		return self
382845
def upgrade_api(request, client, version):
    """"""

    min_ver, max_ver = api_versions._get_server_version_range(client)
    if min_ver <= api_versions.APIVersion(version) <= max_ver:
        client = _nova.novaclient(request, version)
    return client
626425
def bind(self, cls, instance):
        """"""
        self._check_class(cls)
        self._bindings[cls] = lambda: instance
        logger.debug('Bound %s to an instance %s', cls, instance)
        return self
1090599
protected function updateReflectionData()
    {
        $this->log(sprintf('Found %s classes whose reflection data was not cached previously.', count($this->updatedReflectionData)), LogLevel::DEBUG);

        foreach (array_keys($this->updatedReflectionData) as $className) {
            $this->statusCache->set($this->produceCacheIdentifierFromClassName($className), '');
        }

        $data = [];
        $propertyNames = [
            'classReflectionData',
            'classSchemata',
            'annotatedClasses',
            'classesByMethodAnnotations'
        ];

        foreach ($propertyNames as $propertyName) {
            $data[$propertyName] = $this->$propertyName;
        }

        $this->reflectionDataCompiletimeCache->set('ReflectionData', $data);
    }
20016
def refresh(self):
        
        self.client.indices.refresh(index=self.model.search_objects.mapping.index)
728581
def dump(obj, attributes = True, _refset = None):
    ""
    if _refset is None:
        _refset = set()
    if obj is None:
        return None
    elif isinstance(obj, DataObject):        
        if id(obj) in _refset:
            attributes = False
        else:
            _refset.add(id(obj))
        cls = type(obj)
        clsname = getattr(cls, '__module__', '<unknown>') + '.' + getattr(cls, '__name__', '<unknown>')
        baseresult = {'_type': clsname, '_key': obj.getkey()}
        if not attributes:
            return baseresult
        else:
            baseresult.update((k,dump(v, attributes, _refset)) for k,v in vars(obj).items() if k[:1] != '_')
            _refset.remove(id(obj))
        return baseresult
    elif isinstance(obj, ReferenceObject):
        if obj._ref is not None:
            return dump(obj._ref, attributes, _refset)
        else:
            return {'_ref':obj.getkey()}
    elif isinstance(obj, WeakReferenceObject):
        return {'_weakref':obj.getkey()}
    elif isinstance(obj, DataObjectSet):
        return dump(list(obj.dataset()))
    elif isinstance(obj, dict):
        return dict((k, dump(v, attributes, _refset)) for k,v in obj.items())
    elif isinstance(obj, list) or isinstance(obj, tuple) or isinstance(obj, set):
        return [dump(v, attributes, _refset) for v in obj]
    else:
        return obj
1050614
def _reload(self, object, description, data):
        ''''''
        self._object = object
        self._description = description
        self._data = data
1118352
def set_data(self, data):
        """"""
        self.shape = data.shape

        if self._data is None:
            assert self._deferred_init, \
                "Parameter '%s' has not been initialized"%self.name
            self._deferred_init = self._deferred_init[:3] + (data,)
            return

        # if update_on_kvstore, we need to make sure the copy stored in kvstore is in sync
        if self._trainer and self._trainer._kv_initialized and self._trainer._update_on_kvstore:
            if self not in self._trainer._params_to_init:
                self._trainer._reset_kvstore()

        for arr in self._check_and_get(self._data, list):
            arr[:] = data