Ejemplo n.º 1
0
 def __getattr__(self, name):
     if name == '_obj':
         return
     obj = self.get_object()
     if obj is None:
         raise exceptions.ReferencedObjectNotFound(proxy=self)
     return getattr(obj, name)
Ejemplo n.º 2
0
    def _dereference(self, reference):
        """
        Dereference a model proxy object. Return first from the db_store, and
        if it is not there, from the NB DB. Raise a ReferencedObjectNotFound
        exception if it is not in the NB DB either.

        :param reference: Model instance
        :type reference:  model_framework.ModelBase
        :return:          iterator
        :raises:          exceptions.ReferencedObjectNotFound
        """
        item = reference.get_object()
        if item is None:
            item = self.nb_api.get(reference)
        if item is None:
            raise exceptions.ReferencedObjectNotFound(proxy=reference)
        return item