[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/container/browser/contents.py
minor code cleanup; avoid duplication!
Fred L. Drake, Jr.
fdrake at gmail.com
Mon Jun 6 15:42:32 EDT 2005
Log message for revision 30668:
minor code cleanup; avoid duplication!
Changed:
U Zope3/trunk/src/zope/app/container/browser/contents.py
-=-
Modified: Zope3/trunk/src/zope/app/container/browser/contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/contents.py 2005-06-06 19:11:57 UTC (rev 30667)
+++ Zope3/trunk/src/zope/app/container/browser/contents.py 2005-06-06 19:42:32 UTC (rev 30668)
@@ -292,10 +292,7 @@
items.append(zapi.joinPath(container_path, id))
# store the requested operation in the principal annotations:
- user = self.request.principal
- annotationutil = zapi.getUtility(IPrincipalAnnotationUtility)
- annotations = annotationutil.getAnnotations(user)
- clipboard = IPrincipalClipboard(annotations)
+ clipboard = getPrincipalClipboard(self.request)
clipboard.clearContents()
clipboard.addItems('copy', items)
@@ -334,10 +331,7 @@
items.append(zapi.joinPath(container_path, id))
# store the requested operation in the principal annotations:
- user = self.request.principal
- annotationutil = zapi.getUtility(IPrincipalAnnotationUtility)
- annotations = annotationutil.getAnnotations(user)
- clipboard = IPrincipalClipboard(annotations)
+ clipboard = getPrincipalClipboard(self.request)
clipboard.clearContents()
clipboard.addItems('cut', items)
@@ -346,10 +340,7 @@
"""Decide if there is anything to paste
"""
target = self.context
- user = self.request.principal
- annotationutil = zapi.getUtility(IPrincipalAnnotationUtility)
- annotations = annotationutil.getAnnotations(user)
- clipboard = IPrincipalClipboard(annotations)
+ clipboard = getPrincipalClipboard(self.request)
items = clipboard.getContents()
for item in items:
try:
@@ -377,10 +368,7 @@
"""Paste ojects in the user clipboard to the container
"""
target = self.context
- user = self.request.principal
- annotationutil = zapi.getUtility(IPrincipalAnnotationUtility)
- annotations = annotationutil.getAnnotations(user)
- clipboard = IPrincipalClipboard(annotations)
+ clipboard = getPrincipalClipboard(self.request)
items = clipboard.getContents()
moved = False
for item in items:
@@ -411,13 +399,8 @@
if not self.supportsPaste:
return False
- user = self.request.principal
-
- annotationutil = zapi.getUtility(IPrincipalAnnotationUtility)
- annotations = annotationutil.getAnnotations(user)
-
# touch at least one item to in clipboard confirm contents
- clipboard = IPrincipalClipboard(annotations)
+ clipboard = getPrincipalClipboard(self.request)
items = clipboard.getContents()
for item in items:
try:
@@ -454,3 +437,11 @@
return None
else:
return dc.title
+
+
+def getPrincipalClipboard(request):
+ """Return the clipboard based on the request."""
+ user = request.principal
+ annotationutil = zapi.getUtility(IPrincipalAnnotationUtility)
+ annotations = annotationutil.getAnnotations(user)
+ return IPrincipalClipboard(annotations)
More information about the Zope3-Checkins
mailing list