def setdocsink(self, docname): # Set document operation sink callback and add owner with full permissions doc = self.storage.doc_get(docname) if doc.own_opsink: # Prevent crazy recursion doc.own_opsink = False # Add owner with full permissions try: owner = json.loads(document.owner(docname)) self.add_participant(docname, owner) except ValueError: pass # No author could be decoded # Define opsink callback def opsink(op): if self.can_write(None, docname): self.storage.op(docname, op) else: print "Not applying op, you don't have permission" # Set document to use the above function doc.opsink = opsink return doc
def setdocsink(self, docname): # Set document operation sink callback and add owner with full permissions doc = self.storage.doc_get(docname) if doc.own_opsink: # Prevent crazy recursion doc.own_opsink = False # Add owner with full permissions try: owner = json.loads(document.owner(docname)) self.add_participant(docname, owner) except ValueError: pass # No author could be decoded # Define opsink callback def opsink(op): if self.can_write(None, docname): self.storage.op(docname, op) else: print("Not applying op, you don't have permission") # Set document to use the above function doc.opsink = opsink return doc
def owns(self, docname): # Returns bool for whether document owner is a client. owner = document.owner(docname) return owner == ejtpaddress.str_address(self.interface)