Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 90C77200C0D for ; Tue, 31 Jan 2017 12:41:55 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8F58A160B52; Tue, 31 Jan 2017 11:41:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B2D79160B46 for ; Tue, 31 Jan 2017 12:41:54 +0100 (CET) Received: (qmail 81374 invoked by uid 500); 31 Jan 2017 11:41:54 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 81363 invoked by uid 99); 31 Jan 2017 11:41:53 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Jan 2017 11:41:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 7D37218049D for ; Tue, 31 Jan 2017 11:41:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.22 X-Spam-Level: X-Spam-Status: No, score=-5.22 tagged_above=-999 required=6.31 tests=[HK_RANDOM_FROM=0.999, KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id HGeIyge9pGkX for ; Tue, 31 Jan 2017 11:41:51 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id F2F195F253 for ; Tue, 31 Jan 2017 11:41:50 +0000 (UTC) Received: (qmail 81339 invoked by uid 99); 31 Jan 2017 11:41:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Jan 2017 11:41:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 21341DFC40; Tue, 31 Jan 2017 11:41:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mxmrlv@apache.org To: dev@ariatosca.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-ariatosca git commit: review 2 [Forced Update!] Date: Tue, 31 Jan 2017 11:41:50 +0000 (UTC) archived-at: Tue, 31 Jan 2017 11:41:55 -0000 Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields 05b7a2559 -> ea5add2e0 (forced update) review 2 Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ea5add2e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ea5add2e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ea5add2e Branch: refs/heads/ARIA-66-Convert-custom-parser-fields-into-sqla-based-fields Commit: ea5add2e0db27832826e9748fe158e343c21764f Parents: 57dcaa8 Author: mxmrlv Authored: Tue Jan 31 13:24:47 2017 +0200 Committer: mxmrlv Committed: Tue Jan 31 13:41:41 2017 +0200 ---------------------------------------------------------------------- aria/storage/type.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ea5add2e/aria/storage/type.py ---------------------------------------------------------------------- diff --git a/aria/storage/type.py b/aria/storage/type.py index a713d9c..6b3406d 100644 --- a/aria/storage/type.py +++ b/aria/storage/type.py @@ -177,20 +177,20 @@ class _MutableList(mutable.MutableList): except ValueError as e: raise exceptions.StorageError('SQL Storage error: {0}'.format(str(e))) -StrictDictID = namedtuple('StrictDictID', 'key_cls, value_cls') -StrictValue = namedtuple('StrictValue', 'type_cls, listener_cls') +_StrictDictID = namedtuple('_StrictDictID', 'key_cls, value_cls') +_StrictValue = namedtuple('_StrictValue', 'type_cls, listener_cls') class _StrictDict(object): """ This entire class functions as a factory for strict dicts and their listeners. - No type class, and no listener type class is created (and associated) more than once. If a - relevant type class exists it is returned. + No type class, and no listener type class is created more than once. If a relevant type class + exists it is returned. """ _strict_map = {} def __call__(self, key_cls=None, value_cls=None): - strict_dict_map_key = StrictDictID(key_cls=key_cls, value_cls=value_cls) + strict_dict_map_key = _StrictDictID(key_cls=key_cls, value_cls=value_cls) if strict_dict_map_key not in self._strict_map: # Creating the type class itself. this class would be returned (used by the sqlalchemy # Column). @@ -199,17 +199,16 @@ class _StrictDict(object): (Dict, ), {} ) - # Creating the type listening class and associating it with the newly created type. - # The new class inherits from both the _MutableList class and the _StrictListMixin, + # Creating the type listening class. + # The new class inherits from both the _MutableDict class and the _StrictDictMixin, # while setting the necessary _key_cls and _value_cls as class attributes. listener_cls = type( 'StrictMutableDict_{0}_{1}'.format(key_cls.__name__, value_cls.__name__), (_StrictDictMixin, _MutableDict), {'_key_cls': key_cls, '_value_cls': value_cls} ) - listener_cls.associate_with(strict_dict_cls) - self._strict_map[strict_dict_map_key] = StrictValue(type_cls=strict_dict_cls, - listener_cls=listener_cls) + self._strict_map[strict_dict_map_key] = _StrictValue(type_cls=strict_dict_cls, + listener_cls=listener_cls) return self._strict_map[strict_dict_map_key].type_cls @@ -218,9 +217,9 @@ StrictDict = _StrictDict() class _StrictList(object): """ - This entire class functions as a factory for strict dicts and their listeners. - No type class, and no listener type class is created (and associated) more than once. If a - relevant type class exists it is returned. + This entire class functions as a factory for strict lists and their listeners. + No type class, and no listener type class is created more than once. If a relevant type class + exists it is returned. """ _strict_map = {} @@ -234,7 +233,7 @@ class _StrictList(object): (List, ), {} ) - # Creating the type listening class and associating it with the newly created type. + # Creating the type listening class. # The new class inherits from both the _MutableList class and the _StrictListMixin, # while setting the necessary _item_cls as class attribute. listener_cls = type( @@ -242,8 +241,8 @@ class _StrictList(object): (_StrictListMixin, _MutableList), {'_item_cls': item_cls} ) - self._strict_map[item_cls] = StrictValue(type_cls=strict_list_cls, - listener_cls=listener_cls) + self._strict_map[item_cls] = _StrictValue(type_cls=strict_list_cls, + listener_cls=listener_cls) return self._strict_map[item_cls].type_cls @@ -260,14 +259,14 @@ def _mutable_association_listener(mapper, cls): for prop in mapper.column_attrs: column_type = prop.columns[0].type # Dict Listeners - if any(isinstance(column_type, v) for v in strict_dict_type_to_listener): + if type(column_type) in strict_dict_type_to_listener: strict_dict_type_to_listener[type(column_type)].associate_with_attribute( getattr(cls, prop.key)) elif isinstance(column_type, Dict): _MutableDict.associate_with_attribute(getattr(cls, prop.key)) # List Listeners - if any(isinstance(column_type, v) for v in strict_list_type_to_listener): + if type(column_type) in strict_list_type_to_listener: strict_list_type_to_listener[type(column_type)].associate_with_attribute( getattr(cls, prop.key)) elif isinstance(column_type, List):