Skip to content
Browse files

Added support for activity:subject and activity:actor

  • Loading branch information...
1 parent 93cb142 commit 7b383aecfbb185d9092644285ab028349ba68cf2 @mmalone committed Jul 8, 2009
Showing with 36 additions and 1 deletion.
  1. +29 −1 src/feedvalidator/entry.py
  2. +7 −0 src/feedvalidator/extension.py
View
30 src/feedvalidator/entry.py
@@ -121,10 +121,38 @@ def has_author(self):
'author' in self.parent.children or
'author' in self.parent.parent.children)
+ # raise attribute error since an entry can have these, but an objects can.
def do_activity_object(self):
- # raise attribute error since an entry can have this, but an object can't.
raise AttributeError
+ def do_activity_verb(self):
+ raise AttributeError
+
+class activity_subject_id(canonicaluri):
+ def validate(self):
+ self.parent.__dict__['id'] = self.value
+ return canonicaluri.validate(self)
+
+class activity_subject(activity_object):
+ def validate(self):
+ self.parent.__dict__['activity_subject'] = self
+
+ def do_id(self):
+ return activity_subject_id(), nows(), noduplicates(), unique('id',self.parent,DuplicateEntries)
+
+class activity_actor(activity_object):
+ def validate(self):
+ if not 'id' in self.children:
+ self.log(MissingElement({"parent":self.name, "element":"id"}))
+ return
+ if not (hasattr(self.parent.parent, 'activity_subject') or
+ self.parent.parent.activity_subject.id != subject.id):
+ return activity_object.validate(self)
+ # TODO: Could check for mismatched data here and return a warning.
+
+ def do_id(self):
+ return activity_subject_id(), nows(), noduplicates(), unique('id',self.parent,DuplicateEntries)
+
class app_control(validatorBase):
def do_app_draft(self):
return yesno(), noduplicates()
View
7 src/feedvalidator/extension.py
@@ -933,6 +933,10 @@ def do_activity_object(self):
def do_activity_verb(self):
return rfc3987_full()
+ def do_activity_actor(self):
+ from entry import activity_actor
+ return activity_actor()
+
########################################################################
# Extensions that are valid at only at the channel level #
########################################################################
@@ -1069,6 +1073,9 @@ def do_creativeCommons_license(self):
return rfc2396_full()
def do_access_restriction(self):
return access_restriction()
+ def do_activity_subject(self):
+ from entry import activity_subject
+ return activity_subject()
########################################################################
# Validators #

0 comments on commit 7b383ae

Please sign in to comment.
Something went wrong with that request. Please try again.