Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/31#discussion_r90498171
  
    --- Diff: aria/storage/__init__.py ---
    @@ -37,354 +37,93 @@
         * drivers - module, a pool of Aria standard drivers.
         * StorageDriver - class, abstract model implementation.
     """
    -# todo: rewrite the above package documentation
    -# (something like explaning the two types of storage - models and 
resources)
     
    -from collections import namedtuple
    -
    -from .structures import Storage, Field, Model, IterField, PointerField
    -from .drivers import (
    -    ModelDriver,
    -    ResourceDriver,
    -    FileSystemResourceDriver,
    -    FileSystemModelDriver,
    +from aria.logger import LoggerMixin
    +from . import (
    +    models,
    +    exceptions,
    +    api as storage_api,
    +    structures
     )
    -from . import models, exceptions
    +
     
     __all__ = (
         'ModelStorage',
    -    'ResourceStorage',
    -    'FileSystemModelDriver',
         'models',
         'structures',
    -    'Field',
    -    'IterField',
    -    'PointerField',
    -    'Model',
    -    'drivers',
    -    'ModelDriver',
    -    'ResourceDriver',
    -    'FileSystemResourceDriver',
     )
    -# todo: think about package output api's...
    -# todo: in all drivers name => entry_type
    -# todo: change in documentation str => basestring
     
     
    -class ModelStorage(Storage):
    +class Storage(LoggerMixin):
         """
    -    Managing the models storage.
    +    Represents the storage
         """
    -    def __init__(self, driver, model_classes=(), **kwargs):
    -        """
    -        Simple storage client api for Aria applications.
    -        The storage instance defines the tables/documents/code api.
    -
    -        :param ModelDriver driver: model storage driver.
    -        :param model_classes: the models to register.
    -        """
    -        assert isinstance(driver, ModelDriver)
    -        super(ModelStorage, self).__init__(driver, model_classes, **kwargs)
    -
    -    def __getattr__(self, table):
    -        """
    -        getattr is a shortcut to simple api
    -
    -        for Example:
    -        >> storage = ModelStorage(driver=FileSystemModelDriver('/tmp'))
    -        >> node_table = storage.node
    -        >> for node in node_table:
    -        >>     print node
    -
    -        :param str table: table name to get
    -        :return: a storage object that mapped to the table name
    -        """
    -        return super(ModelStorage, self).__getattr__(table)
    -
    -    def register(self, model_cls):
    -        """
    -        Registers the model type in the resource storage manager.
    -        :param model_cls: the model to register.
    -        """
    -        model_name = generate_lower_name(model_cls)
    -        model_api = _ModelApi(model_name, self.driver, model_cls)
    -        self.registered[model_name] = model_api
    -
    -        for pointer_schema_register in model_api.pointer_mapping.values():
    -            model_cls = pointer_schema_register.model_cls
    -            self.register(model_cls)
    -
    -_Pointer = namedtuple('_Pointer', 'name, is_iter')
    -
    -
    -class _ModelApi(object):
    -    def __init__(self, name, driver, model_cls):
    -        """
    -        Managing the model in the storage, using the driver.
    -
    -        :param basestring name: the name of the model.
    -        :param ModelDriver driver: the driver which supports this model in 
the storage.
    -        :param Model model_cls: table/document class model.
    -        """
    -        assert isinstance(driver, ModelDriver)
    -        assert issubclass(model_cls, Model)
    -        self.name = name
    -        self.driver = driver
    -        self.model_cls = model_cls
    -        self.pointer_mapping = {}
    -        self._setup_pointers_mapping()
    -
    -    def _setup_pointers_mapping(self):
    -        for field_name, field_cls in vars(self.model_cls).items():
    -            if not(isinstance(field_cls, PointerField) and field_cls.type):
    -                continue
    -            pointer_key = _Pointer(field_name, 
is_iter=isinstance(field_cls, IterField))
    -            self.pointer_mapping[pointer_key] = self.__class__(
    -                name=generate_lower_name(field_cls.type),
    -                driver=self.driver,
    -                model_cls=field_cls.type)
    -
    -    def __iter__(self):
    -        return self.iter()
    +    def __init__(self, api, items=(), api_params=None, **kwargs):
    --- End diff --
    
    api_cls, api_params, items


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to