ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxmrlv <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #31: ARIA-30-SQL-based-storage-implementati...
Date Mon, 05 Dec 2016 15:15:46 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/31#discussion_r90882506
  
    --- Diff: aria/storage/sql_mapi.py ---
    @@ -54,19 +53,47 @@ def get(self, entry_id, include=None, filters=None, locking=False,
**kwargs):
                 )
             return result
     
    -    def iter(self,
    +    def get_by_name(self, entry_name, include=None, **kwargs):
    +        result = self.list(include=include, filters={'name': entry_name})
    +        if not result:
    +            raise exceptions.StorageError(
    +                'Requested {0} with NAME `{1}` was not found'
    +                .format(self.model_cls.__name__, entry_name)
    +            )
    +        elif len(result) > 1:
    +            raise exceptions.StorageError(
    +                'Requested {0} with NAME `{1}` returned more than 1 value'
    +                .format(self.model_cls.__name__, entry_name)
    +            )
    +        else:
    +            return result[0]
    +
    +    def list(self,
                  include=None,
                  filters=None,
                  pagination=None,
                  sort=None,
                  **kwargs):
    -        """Return a (possibly empty) list of `model_class` results
    -        """
             query = self._get_query(include, filters, sort)
     
    -        results, _, _, _ = self._paginate(query, pagination)
    +        results, total, size, offset = self._paginate(query, pagination)
     
    -        for result in results:
    +        return ListResult(
    +            items=results,
    +            metadata=dict(total=total,
    +                          size=size,
    +                          offset=offset)
    +        )
    +
    +    def iter(self,
    +             include=None,
    +             filters=None,
    +             sort=None,
    +             **kwargs):
    +        """Return a (possibly empty) list of `model_class` results
    +        """
    +        query = self._get_query(include, filters, sort)
    --- End diff --
    
    return from here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message