aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyapd/objects.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/pyapd/objects.py b/pyapd/objects.py
index 6750b09..2fa2e03 100644
--- a/pyapd/objects.py
+++ b/pyapd/objects.py
@@ -3,7 +3,6 @@ import json
class Object():
PROPERTIES = [
- 'id',
'type',
'attachment',
'attributedTo',
@@ -41,13 +40,19 @@ class Object():
for p in self.PROPERTIES:
if p in kw:
setattr(self, "ap_"+p, kw[p])
+ if 'id' in kw:
+ self.ap_id = kw['id']
+ else:
+ self.ap_id = self._generate_id()
@classmethod
def from_jsons(cls, data: str):
return cls(**json.loads(data))
def to_jsonable(self):
- data = {}
+ data = {
+ 'id': self.ap_id,
+ }
for p in self.PROPERTIES:
v = getattr(self, "ap_"+p, None)
if v is not None:
@@ -56,3 +61,6 @@ class Object():
def to_jsons(self):
return json.dumps(self.to_jsonable())
+
+ def _generate_id(self):
+ raise NotImplementedError