[Checkins] SVN: z3c.contents/trunk/src/z3c/contents/ Be smarter to
clipboard lookup
Roger Ineichen
roger at projekt01.ch
Thu Feb 14 05:31:25 EST 2008
Log message for revision 83824:
Be smarter to clipboard lookup
Configure default template for Contents page
Added default column adapter configuration for Contents page
Changed:
U z3c.contents/trunk/src/z3c/contents/browser.py
A z3c.contents/trunk/src/z3c/contents/browser.zcml
A z3c.contents/trunk/src/z3c/contents/configure.zcml
-=-
Modified: z3c.contents/trunk/src/z3c/contents/browser.py
===================================================================
--- z3c.contents/trunk/src/z3c/contents/browser.py 2008-02-14 10:27:12 UTC (rev 83823)
+++ z3c.contents/trunk/src/z3c/contents/browser.py 2008-02-14 10:31:24 UTC (rev 83824)
@@ -44,11 +44,13 @@
_ = zope.i18nmessageid.MessageFactory('z3c')
-def getPrincipalClipboard(request):
+def queryPrincipalClipboard(request):
"""Return the clipboard based on the request."""
user = request.principal
- annotations = IAnnotations(user)
- return IPrincipalClipboard(annotations)
+ annotations = IAnnotations(user, None)
+ if annotations is None:
+ return None
+ return IPrincipalClipboard(annotations, None)
def getDCTitle(ob):
@@ -102,6 +104,7 @@
# first setup columns and process the items as selected if any
super(ContentsPage, self).update()
# second find out if we support paste
+ self.clipboard = queryPrincipalClipboard(self.request)
if self.allowPaste:
self.supportsPaste = self.pasteable()
self.updateWidgets()
@@ -115,8 +118,9 @@
def pasteable(self):
"""Decide if there is anything to paste."""
target = self.context
- clipboard = getPrincipalClipboard(self.request)
- items = clipboard.getContents()
+ if self.clipboard is None:
+ return False
+ items = self.clipboard.getContents()
for item in items:
try:
obj = api.traverse(self.context, item['target'])
@@ -143,8 +147,7 @@
if not self.supportsPaste:
return False
# touch at least one item in clipboard to confirm contents
- clipboard = getPrincipalClipboard(self.request)
- items = clipboard.getContents()
+ items = self.clipboard.getContents()
for item in items:
try:
api.traverse(self.context, item['target'])
@@ -181,9 +184,8 @@
self.status = self.copyItemsSelected
# store the requested operation in the principal annotations:
- clipboard = getPrincipalClipboard(self.request)
- clipboard.clearContents()
- clipboard.addItems('copy', items)
+ self.clipboard.clearContents()
+ self.clipboard.addItems('copy', items)
@button.buttonAndHandler(_('Cut'), name='cut')
def handleCut(self, action):
@@ -212,14 +214,12 @@
self.status = self.cutItemsSelected
# store the requested operation in the principal annotations:
- clipboard = getPrincipalClipboard(self.request)
- clipboard.clearContents()
- clipboard.addItems('cut', items)
+ self.clipboard.clearContents()
+ self.clipboard.addItems('cut', items)
@button.buttonAndHandler(_('Paste'), name='paste')
def handlePaste(self, action):
- clipboard = getPrincipalClipboard(self.request)
- items = clipboard.getContents()
+ items = self.clipboard.getContents()
moved = False
not_pasteable_ids = []
for item in items:
@@ -250,7 +250,7 @@
if moved:
# Clear the clipboard if we do a move, but not if we only do a copy
- clipboard.clearContents()
+ self.clipboard.clearContents()
if not_pasteable_ids != []:
# Show the ids of objects that can't be pasted because
Added: z3c.contents/trunk/src/z3c/contents/browser.zcml
===================================================================
--- z3c.contents/trunk/src/z3c/contents/browser.zcml (rev 0)
+++ z3c.contents/trunk/src/z3c/contents/browser.zcml 2008-02-14 10:31:24 UTC (rev 83824)
@@ -0,0 +1,13 @@
+<configure
+ xmlns:zope="http://namespaces.zope.org/zope"
+ xmlns="http://namespaces.zope.org/browser"
+ xmlns:z3c="http://namespaces.zope.org/z3c"
+ i18n_domain="zam">
+
+ <z3c:template
+ template="contents.pt"
+ for=".browser.ContentsPage"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ />
+
+</configure>
Property changes on: z3c.contents/trunk/src/z3c/contents/browser.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.contents/trunk/src/z3c/contents/configure.zcml
===================================================================
--- z3c.contents/trunk/src/z3c/contents/configure.zcml (rev 0)
+++ z3c.contents/trunk/src/z3c/contents/configure.zcml 2008-02-14 10:31:24 UTC (rev 83824)
@@ -0,0 +1,43 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="zam">
+
+ <adapter
+ name="checkBoxColumn"
+ factory="z3c.table.column.CheckBoxColumn"
+ for="zope.app.container.interfaces.IContainer
+ zope.interface.Interface
+ z3c.contents.interfaces.IContentsPage"
+ provides="z3c.table.interfaces.IColumn"
+ />
+
+ <adapter
+ name="renameColumn"
+ factory="z3c.contents.column.RenameColumn"
+ for="zope.app.container.interfaces.IContainer
+ zope.interface.Interface
+ z3c.contents.interfaces.IContentsPage"
+ provides="z3c.table.interfaces.IColumn"
+ />
+
+ <adapter
+ name="createdColumn"
+ factory="z3c.table.column.CreatedColumn"
+ for="zope.app.container.interfaces.IContainer
+ zope.interface.Interface
+ z3c.contents.interfaces.IContentsPage"
+ provides="z3c.table.interfaces.IColumn"
+ />
+
+ <adapter
+ name="modifiedColumn"
+ factory="z3c.table.column.ModifiedColumn"
+ for="zope.app.container.interfaces.IContainer
+ zope.interface.Interface
+ z3c.contents.interfaces.IContentsPage"
+ provides="z3c.table.interfaces.IColumn"
+ />
+
+ <include file="browser.zcml" />
+
+</configure>
Property changes on: z3c.contents/trunk/src/z3c/contents/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list