Skip to content
Browse files

Implemented helper functions to set/remove marker interfaces while co…

…rrectly handling the events (ON-402)
  • Loading branch information...
1 parent c758a9c commit 1aed9f9746b3ac5848efff354e86a3c086939883 @mmikulicic mmikulicic committed May 22, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 opennode/oms/model/form.py
View
16 opennode/oms/model/form.py
@@ -215,3 +215,19 @@ def apply(self):
updated[k] = getattr(self.__dict__['obj'], k)
if updated:
handle(self.__dict__['obj'], ModelModifiedEvent(original_attrs, updated))
+
+
+def alsoProvides(obj, interface):
+ form = ApplyRawData({'features': '+' + interface.__name__}, obj)
+ if not form.errors:
+ form.apply()
+ else:
+ raise Exception("Cannot set marker interface %s" % interface)
+
+
+def noLongerProvides(obj, interface):
+ form = ApplyRawData({'features': '-' + interface.__name__}, obj)
+ if not form.errors:
+ form.apply()
+ else:
+ raise Exception("Cannot remove marker interface %s" % interface)

0 comments on commit 1aed9f9

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