Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/active_document/metadata.py
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-04-17 05:13:40 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-04-17 06:03:32 (GMT)
commitceb6b7fdeed677344aa43c3a8fe663cfca81e3df (patch)
treeee6237dbcf7df6b8a50e0f5d5bebceaed957f959 /active_document/metadata.py
parent8ffe8f9aaf658c45b3b865cb793dd22463c43bdc (diff)
Started work to keep votes related properties out of regular onesactive_document-votes.merged
Diffstat (limited to 'active_document/metadata.py')
-rw-r--r--active_document/metadata.py33
1 files changed, 6 insertions, 27 deletions
diff --git a/active_document/metadata.py b/active_document/metadata.py
index f73a6d1..cbfa6c8 100644
--- a/active_document/metadata.py
+++ b/active_document/metadata.py
@@ -328,18 +328,19 @@ class ActiveProperty(StoredProperty):
return self._boolean
-class AggregatorProperty(Property, BrowsableProperty):
+class VoteProperty(Property, BrowsableProperty):
"""Property that aggregates arbitrary values.
This properties is repesented by boolean value (int in string notation)
- that shows that `AggregatorProperty.value` is aggregated or not.
- After setting this property, `AggregatorProperty.value` will be added or
+ that shows that `VoteProperty.value` is aggregated or not.
+ After setting this property, `VoteProperty.value` will be added or
removed from the aggregatation list.
"""
def __init__(self, name, counter):
- Property.__init__(self, name, typecast=bool, default=False)
+ Property.__init__(self, name, typecast=bool, default=False,
+ permissions=env.ACCESS_READ)
self._counter = counter
@property
@@ -348,15 +349,9 @@ class AggregatorProperty(Property, BrowsableProperty):
return self._counter
@property
- def value(self):
+ def voter(self):
return env.principal.user
- def encode(self, value):
- return AggregatedValue(self.value, bool(value))
-
- def decode(self, value):
- return bool(value)
-
class CounterProperty(ActiveProperty):
"""Only index property that can be changed only by incrementing.
@@ -396,22 +391,6 @@ class BlobProperty(Property):
return self._mime_type
-class AggregatedValue(int):
-
- def __new__(cls, value, enabled):
- self = int.__new__(cls, int(enabled))
- self.value = value
- return self
-
- def __cmp__(self, other):
- if hasattr(other, 'value'):
- # pylint: disable-msg=E1101
- diff = cmp(self.value, other.value)
- if diff:
- return diff
- return int.__cmp__(self, other)
-
-
class Method(object):
def __init__(self, cb=None, cmd=None, http_method='GET',