source: mauRepo/MolesManager/trunk/src/ea_model/iso_19103_2005_schema_language/basic_types/implementation/names/typename.py @ 8160

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/ea_model/iso_19103_2005_schema_language/basic_types/implementation/names/typename.py@8160
Revision 8160, 1.5 KB checked in by mnagni, 8 years ago (diff)

This new DB library adds better hash algorithm and a bug fix for the classes eq method

Line 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21from ea_model.iso_19103_2005_schema_language.basic_types.implementation.names.localname import  LocalName
22from ascore.utils import has_value, collectionProofHash
23
24'''
25Created on 13-Mar-2012 11:08:07
26
27@author: mnagni
28'''
29
30class TypeName(LocalName):
31    '''
32        Represents a data entity defined in a UML diagram and supposed to
33        be persisted in a relational database.
34 
35        This class has been genererated automatically using the Apache Velocity project.
36    '''
37    '''
38        Please note that any access to the inner attributes should be done using
39        the given get/set methods and NOT accessing them directly.
40    '''
41    def __init__(self):
42        self._localname = LocalName()   
43
44        self.aName = None
45        self.scope = None
46        super(TypeName, self).__init__()
47
48    @property
49    def scope(self):   
50        return self._localname.scope
51
52    @scope.setter
53    def scope(self, value):     
54            self._localname.scope = value
55
56    def __key(self):
57        return (self.aName, self.scope)
58
59    def __eq__(self, y):
60        if type(self) != type(y):
61            return False
62        '''
63        Cannot compare classes which do not define a "__key" attribute
64        '''
65        if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
66            return self.__key() == y.__key()
67        return id(self) == id(y)
68
69    def __hash__(self):
70        return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.