Repository: incubator-ariatosca
Updated Branches:
  refs/heads/Misc_fixes [created] 3eeb4a468


Misc_fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/3eeb4a46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/3eeb4a46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/3eeb4a46

Branch: refs/heads/Misc_fixes
Commit: 3eeb4a468aecadb79dae7d4ab3f85bf50dd06ac5
Parents: 860d69b
Author: mxmrlv <mxm...@gmail.com>
Authored: Wed Jan 4 23:33:12 2017 +0200
Committer: mxmrlv <mxm...@gmail.com>
Committed: Wed Jan 4 23:33:12 2017 +0200

----------------------------------------------------------------------
 aria/storage/base_model.py |  4 +--
 aria/storage/structure.py  | 30 ++++++++++++++---------
 aria/storage/type.py       | 54 ++++++++---------------------------------
 requirements.txt           |  6 ++---
 4 files changed, 33 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3eeb4a46/aria/storage/base_model.py
----------------------------------------------------------------------
diff --git a/aria/storage/base_model.py b/aria/storage/base_model.py
index c7eb27c..d1aebf2 100644
--- a/aria/storage/base_model.py
+++ b/aria/storage/base_model.py
@@ -146,7 +146,7 @@ class ExecutionBase(ModelMixin):
     VALID_TRANSITIONS = {
         PENDING: [STARTED, CANCELLED],
         STARTED: END_STATES + [CANCELLING],
-        CANCELLING: END_STATES
+        CANCELLING: END_STATES + [FORCE_CANCELLING]
     }
 
     @orm.validates('status')
@@ -156,7 +156,7 @@ class ExecutionBase(ModelMixin):
             current_status = getattr(self, key)
         except AttributeError:
             return
-        valid_transitions = 
ExecutionBase.VALID_TRANSITIONS.get(current_status, [])
+        valid_transitions = self.VALID_TRANSITIONS.get(current_status, [])
         if all([current_status is not None,
                 current_status != value,
                 value not in valid_transitions]):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3eeb4a46/aria/storage/structure.py
----------------------------------------------------------------------
diff --git a/aria/storage/structure.py b/aria/storage/structure.py
index d222c94..9bf1286 100644
--- a/aria/storage/structure.py
+++ b/aria/storage/structure.py
@@ -124,25 +124,31 @@ class ModelMixin(object):
                             remote_side=remote_side_str,
                             post_update=True)
 
-    def to_dict(self, suppress_error=False):
+    def to_dict(self, fields=None, suppress_error=False):
         """Return a dict representation of the model
 
         :param suppress_error: If set to True, sets `None` to attributes that
         it's unable to retrieve (e.g., if a relationship wasn't established
         yet, and so it's impossible to access a property through it)
         """
-        if suppress_error:
-            res = dict()
-            for field in self.fields():
-                try:
-                    field_value = getattr(self, field)
-                except AttributeError:
+        res = dict()
+        fields = fields or self.fields()
+        for field in fields:
+            try:
+                field_value = getattr(self, field)
+            except AttributeError:
+                # Can't simply call here `self.to_response()` because 
inheriting
+                # class might override it, but we always need the same code 
here
+                if suppress_error:
                     field_value = None
-                res[field] = field_value
-        else:
-            # Can't simply call here `self.to_response()` because inheriting
-            # class might override it, but we always need the same code here
-            res = dict((f, getattr(self, f)) for f in self.fields())
+                else:
+                    raise
+            if isinstance(field_value, list):
+                field_value = list(field_value)
+            elif isinstance(field_value, dict):
+                field_value = dict(field_value)
+            res[field] = field_value
+
         return res
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3eeb4a46/aria/storage/type.py
----------------------------------------------------------------------
diff --git a/aria/storage/type.py b/aria/storage/type.py
index 84fd8dc..ab50b0f 100644
--- a/aria/storage/type.py
+++ b/aria/storage/type.py
@@ -60,63 +60,29 @@ class List(_MutableType):
         return list
 
 
-class _MutableDict(mutable.Mutable, dict):
+class _MutableDict(mutable.MutableDict):
     """
     Enables tracking for dict values.
     """
     @classmethod
     def coerce(cls, key, value):
         "Convert plain dictionaries to MutableDict."
+        try:
+            return mutable.MutableDict.coerce(key, value)
+        except ValueError as e:
+            raise exceptions.StorageError('SQL Storage error: 
{0}'.format(str(e)))
 
-        if not isinstance(value, cls):
-            if isinstance(value, dict):
-                return cls(value)
 
-            # this call will raise ValueError
-            try:
-                return mutable.Mutable.coerce(key, value)
-            except ValueError as e:
-                raise exceptions.StorageError('SQL Storage error: 
{0}'.format(str(e)))
-        else:
-            return value
-
-    def __setitem__(self, key, value):
-        "Detect dictionary set events and emit change events."
-
-        dict.__setitem__(self, key, value)
-        self.changed()
-
-    def __delitem__(self, key):
-        "Detect dictionary del events and emit change events."
-
-        dict.__delitem__(self, key)
-        self.changed()
-
-
-class _MutableList(mutable.Mutable, list):
+class _MutableList(mutable.MutableList):
 
     @classmethod
     def coerce(cls, key, value):
         "Convert plain dictionaries to MutableDict."
+        try:
+            return mutable.MutableList.coerce(key, value)
+        except ValueError as e:
+            raise exceptions.StorageError('SQL Storage error: 
{0}'.format(str(e)))
 
-        if not isinstance(value, cls):
-            if isinstance(value, list):
-                return cls(value)
-
-            # this call will raise ValueError
-            try:
-                return mutable.Mutable.coerce(key, value)
-            except ValueError as e:
-                raise exceptions.StorageError('SQL Storage error: 
{0}'.format(str(e)))
-        else:
-            return value
-
-    def __setitem__(self, key, value):
-        list.__setitem__(self, key, value)
-        self.changed()
-
-    def __delitem__(self, key):
-        list.__delitem__(self, key)
 
 _MutableList.associate_with(List)
 _MutableDict.associate_with(Dict)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3eeb4a46/requirements.txt
----------------------------------------------------------------------
diff --git a/requirements.txt b/requirements.txt
index 0005a5e..2886e2a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,7 +11,7 @@
 # limitations under the License.
 
 PyYAML==3.10
-networkx==1.9
+networkx==1.8.1
 requests==2.7.0
 retrying==1.3.3
 blinker==1.4
@@ -20,9 +20,9 @@ ordereddict==1.1 ; python_version < '2.7'
 total-ordering==0.1.0 ; python_version < '2.7'
 jsonpickle
 ruamel.yaml==0.11.15
-Jinja2==2.8
+Jinja2==2.7.2
 shortuuid==0.4.3
 CacheControl[filecache]==0.11.6
 clint==0.5.1
 SQLAlchemy==1.1.4
-wagon==0.5.0
+wagon==0.3.2

Reply via email to