Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/util.py
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2006-06-14 18:42:44 (GMT)
committer Dan Williams <dcbw@redhat.com>2006-06-14 18:42:44 (GMT)
commit1cdaf97f20e84ea9cb80e97708f10627e24b6988 (patch)
tree51404b0ca08e383c66251cb4e881578dca0e3dc0 /sugar/util.py
parent55f538253c3dfdd109f0e34bb828948f037f1df5 (diff)
Switch from Groups to grouping services based on activity UID
Diffstat (limited to 'sugar/util.py')
-rw-r--r--sugar/util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/sugar/util.py b/sugar/util.py
index 9c15edb..6f70495 100644
--- a/sugar/util.py
+++ b/sugar/util.py
@@ -19,3 +19,20 @@ def _sha_data(data):
def unique_id(data = ''):
data_string = "%s%s%s" % (time.time(), random.randint(10000, 100000), data)
return _stringify_sha(_sha_data(data_string))
+
+
+ACTIVITY_UID_LEN = 40
+
+def is_hex(s):
+ return s.strip(string.hexdigits) == ''
+
+def validate_activity_uid(uid):
+ """Validate an activity UID."""
+ if type(uid) != type(""):
+ return False
+ if len(uid) != ACTIVITY_UID_LEN:
+ return False
+ if not is_hex(uid):
+ return False
+ return True
+