Back to index

plone3  3.1.7
Classes | Functions | Variables
plone.app.contentrules.rule Namespace Reference

Classes

class  Rule

Functions

def get_assignments
def rule_removed
def container_moved
def container_removed

Variables

string ANNOTATION_KEY = "plone.app.contentrules.ruleassignments"

Function Documentation

def plone.app.contentrules.rule.container_moved (   container,
  event 
)

Definition at line 50 of file rule.py.

00050 
00051 def container_moved(container, event):
00052     
00053     if event.oldParent is None or event.newParent is None or event.oldName is None:
00054         return
00055     
00056     assignable = IRuleAssignmentManager(container, None)
00057     storage = queryUtility(IRuleStorage)
00058     
00059     if assignable is None or storage is None:
00060         return
00061     
00062     old_path = "%s/%s" % ('/'.join(event.oldParent.getPhysicalPath()), event.oldName,)
00063     new_path = '/'.join(container.getPhysicalPath())
00064     
00065     if aq_base(event.object) is not aq_base(container):
00066         new_path_of_moved = '/'.join(event.object.getPhysicalPath())
00067         old_path = old_path + new_path[len(new_path_of_moved):]
00068     
00069     for rule_name in assignable.keys():
00070         rule = storage.get(rule_name, None)
00071         if rule is not None:
00072             assignments = get_assignments(rule)
00073             if old_path in assignments:
00074                 assignments.remove(old_path)
00075                 assignments.insert(new_path)
    

Here is the call graph for this function:

def plone.app.contentrules.rule.container_removed (   container,
  event 
)

Definition at line 76 of file rule.py.

00076 
00077 def container_removed(container, event):
00078     
00079     assignable = IRuleAssignmentManager(container, None)
00080     storage = queryUtility(IRuleStorage)
00081     
00082     if assignable is None or storage is None:
00083         return
00084     
00085     path = '/'.join(container.getPhysicalPath())
00086     for rule_name in assignable.keys():
00087         rule = storage.get(rule_name, None)
00088         if rule is not None:
00089             assignments = get_assignments(rule)
00090             if path in assignments:
                assignments.remove(path)

Here is the call graph for this function:

Definition at line 28 of file rule.py.

00028 
00029 def get_assignments(rule):
00030     annotations = IAnnotations(rule)
00031     return annotations.setdefault(ANNOTATION_KEY, OOSet())
00032     
00033 # Events that keep track of rule-to-assignment mappings
    

Here is the caller graph for this function:

def plone.app.contentrules.rule.rule_removed (   rule,
  event 
)

Definition at line 34 of file rule.py.

00034 
00035 def rule_removed(rule, event):
00036     
00037     storage = queryUtility(IRuleStorage)
00038     rule_name = rule.__name__
00039     
00040     if storage is None:
00041         return
00042     
00043     portal = getUtility(ISiteRoot)
00044     for path in get_assignments(rule):
00045         container = portal.unrestrictedTraverse(path)
00046         if container is not None:
00047             assignable = IRuleAssignmentManager(container, None)
00048             if assignable is not None and rule_name in assignable:
00049                 del assignable[rule_name]
    

Here is the call graph for this function:


Variable Documentation

string plone.app.contentrules.rule.ANNOTATION_KEY = "plone.app.contentrules.ruleassignments"

Definition at line 15 of file rule.py.