source: geniuswebcore/geniusweb/references/ProfileRef.py@ 99

Last change on this file since 99 was 96, checked in by Bart Vastenhouw, 2 years ago

Fixed small issues in domaineditor.

File size: 1.2 KB
Line 
1from pyson.JsonGetter import JsonGetter
2from pyson.JsonValue import JsonValue
3from uri.uri import URI # type: ignore
4
5from geniusweb.references.Reference import Reference
6
7
8class ProfileRef (Reference):
9 '''
10 A URI reference to get a copy of a profile. This usually is a "ws://"
11 (websocket) URI, allowing users (parties) to get notifications if the profile
12 is changed.
13 <p>
14 In debugging scenarios, this is usually a "file://" URI, in which case the
15 profile is assumed to be static during the run. Parties that support
16 debugging eg with the simplerunner should support the file: protocol.
17 '''
18
19 def __init__(self, uri:URI):
20 # EXTRA: we check that the URI is not completely empty.
21 # This to get similar behaviour as Java
22 if uri == None or (uri.getHost() == None and uri.getPath() == None):
23 raise ValueError("profile=null")
24 self._profile = uri
25
26 @JsonValue()
27 def getURI(self) -> URI:
28 return self._profile
29
30 def __repr__(self):
31 return "ProfileRef[" + str(self._profile) + "]"
32
33 def __eq__(self, other):
34 return isinstance(other, self.__class__) and \
35 self._profile == other._profile
36
37 def __hash__(self):
38 '''
39 support for using this in dict etc
40 '''
41 return hash(str(self._profile))
Note: See TracBrowser for help on using the repository browser.