[Checkins] SVN: z3c.tabular/trunk/ Convert all files to native line endings.
Marius Gedminas
cvs-admin at zope.org
Tue Feb 26 17:51:39 UTC 2013
Log message for revision 129855:
Convert all files to native line endings.
Changed:
UU z3c.tabular/trunk/AUTHOR.txt
UU z3c.tabular/trunk/README.txt
UU z3c.tabular/trunk/src/z3c/__init__.py
UU z3c.tabular/trunk/src/z3c/tabular/__init__.py
UU z3c.tabular/trunk/src/z3c/tabular/browser.zcml
UU z3c.tabular/trunk/src/z3c/tabular/configure.zcml
UU z3c.tabular/trunk/src/z3c/tabular/formtable.pt
UU z3c.tabular/trunk/src/z3c/tabular/interfaces.py
UU z3c.tabular/trunk/src/z3c/tabular/subformtable.pt
UU z3c.tabular/trunk/src/z3c/tabular/table.pt
UU z3c.tabular/trunk/src/z3c/tabular/table.py
UU z3c.tabular/trunk/src/z3c/tabular/testing.py
UU z3c.tabular/trunk/src/z3c/tabular/tests.py
-=-
Modified: z3c.tabular/trunk/AUTHOR.txt
===================================================================
--- z3c.tabular/trunk/AUTHOR.txt 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/AUTHOR.txt 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1 +1 @@
-Roger Ineichen (roger <at> projekt01 <dot> ch)
+Roger Ineichen (roger <at> projekt01 <dot> ch)
Property changes on: z3c.tabular/trunk/AUTHOR.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/README.txt
===================================================================
--- z3c.tabular/trunk/README.txt 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/README.txt 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,2 +1,2 @@
-This package provides a table implementation including form support for Zope3
-based on z3c.form and z3c.table.
+This package provides a table implementation including form support for Zope3
+based on z3c.form and z3c.table.
Property changes on: z3c.tabular/trunk/README.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/__init__.py
===================================================================
--- z3c.tabular/trunk/src/z3c/__init__.py 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/__init__.py 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,7 +1,7 @@
-try:
- # Declare this a namespace package if pkg_resources is available.
- import pkg_resources
- pkg_resources.declare_namespace('z3c')
-except ImportError:
- pass
-
+try:
+ # Declare this a namespace package if pkg_resources is available.
+ import pkg_resources
+ pkg_resources.declare_namespace('z3c')
+except ImportError:
+ pass
+
Property changes on: z3c.tabular/trunk/src/z3c/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/__init__.py
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/__init__.py 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/__init__.py 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1 +1 @@
-# make a package
+# make a package
Property changes on: z3c.tabular/trunk/src/z3c/tabular/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/browser.zcml
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/browser.zcml 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/browser.zcml 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,43 +1,43 @@
-<configure
- xmlns:zope="http://namespaces.zope.org/zope"
- xmlns="http://namespaces.zope.org/browser"
- xmlns:z3c="http://namespaces.zope.org/z3c"
- i18n_domain="z3c">
-
- <z3c:template
- template="table.pt"
- for=".interfaces.ITemplateTable"
- layer="zope.publisher.interfaces.browser.IBrowserRequest"
- />
-
- <z3c:template
- template="formtable.pt"
- for=".interfaces.IFormTable"
- layer="zope.publisher.interfaces.browser.IBrowserRequest"
- />
-
- <z3c:template
- template="subformtable.pt"
- for=".interfaces.ISubFormTable"
- layer="zope.publisher.interfaces.browser.IBrowserRequest"
- />
-
- <z3c:macro
- name="z3c-tabular-table"
- template="formtable.pt"
- layer="zope.publisher.interfaces.browser.IBrowserRequest"
- />
-
- <z3c:macro
- name="z3c-tabular-formtable"
- template="formtable.pt"
- layer="zope.publisher.interfaces.browser.IBrowserRequest"
- />
-
- <z3c:macro
- name="z3c-tabular-subformtable"
- template="formtable.pt"
- layer="zope.publisher.interfaces.browser.IBrowserRequest"
- />
-
-</configure>
+<configure
+ xmlns:zope="http://namespaces.zope.org/zope"
+ xmlns="http://namespaces.zope.org/browser"
+ xmlns:z3c="http://namespaces.zope.org/z3c"
+ i18n_domain="z3c">
+
+ <z3c:template
+ template="table.pt"
+ for=".interfaces.ITemplateTable"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ />
+
+ <z3c:template
+ template="formtable.pt"
+ for=".interfaces.IFormTable"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ />
+
+ <z3c:template
+ template="subformtable.pt"
+ for=".interfaces.ISubFormTable"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ />
+
+ <z3c:macro
+ name="z3c-tabular-table"
+ template="formtable.pt"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ />
+
+ <z3c:macro
+ name="z3c-tabular-formtable"
+ template="formtable.pt"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ />
+
+ <z3c:macro
+ name="z3c-tabular-subformtable"
+ template="formtable.pt"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ />
+
+</configure>
Property changes on: z3c.tabular/trunk/src/z3c/tabular/browser.zcml
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/configure.zcml
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/configure.zcml 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/configure.zcml 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,7 +1,7 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- i18n_domain="z3c">
-
- <include file="browser.zcml" />
-
-</configure>
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="z3c">
+
+ <include file="browser.zcml" />
+
+</configure>
Property changes on: z3c.tabular/trunk/src/z3c/tabular/configure.zcml
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/formtable.pt
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/formtable.pt 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/formtable.pt 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,19 +1,19 @@
-<div metal:define-macro="z3c-tabular-formtable"
- metal:extend-macro="macro:form">
- <div metal:fill-slot="main"
- tal:define="batch view/renderBatch">
- <div class="tabluarTable">
- <tal:block replace="structure view/renderTable">
- table
- </tal:block>
- </div>
- <div class="batch" tal:condition="batch">
- <tal:block replace="structure batch">
- table
- </tal:block>
- </div>
- <div class="tabluarForm">
- <div metal:use-macro="macro:widget-rows" />
- </div>
- </div>
-</div>
+<div metal:define-macro="z3c-tabular-formtable"
+ metal:extend-macro="macro:form">
+ <div metal:fill-slot="main"
+ tal:define="batch view/renderBatch">
+ <div class="tabluarTable">
+ <tal:block replace="structure view/renderTable">
+ table
+ </tal:block>
+ </div>
+ <div class="batch" tal:condition="batch">
+ <tal:block replace="structure batch">
+ table
+ </tal:block>
+ </div>
+ <div class="tabluarForm">
+ <div metal:use-macro="macro:widget-rows" />
+ </div>
+ </div>
+</div>
Property changes on: z3c.tabular/trunk/src/z3c/tabular/formtable.pt
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/interfaces.py
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/interfaces.py 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/interfaces.py 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,35 +1,35 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id:$
-"""
-__docformat__ = "reStructuredText"
-
-import z3c.table.interfaces
-
-
-class ITemplateTable(z3c.table.interfaces.ITable):
- """Template aware table."""
-
-
-class IFormTable(ITemplateTable):
- """Table including a form setup."""
-
-
-class IDeleteFormTable(IFormTable):
- """Delete button aware table including a form setup."""
-
-
-class ISubFormTable(IDeleteFormTable):
- """Table including a sub form for one selected item."""
+##############################################################################
+#
+# Copyright (c) 2008 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+import z3c.table.interfaces
+
+
+class ITemplateTable(z3c.table.interfaces.ITable):
+ """Template aware table."""
+
+
+class IFormTable(ITemplateTable):
+ """Table including a form setup."""
+
+
+class IDeleteFormTable(IFormTable):
+ """Delete button aware table including a form setup."""
+
+
+class ISubFormTable(IDeleteFormTable):
+ """Table including a sub form for one selected item."""
Property changes on: z3c.tabular/trunk/src/z3c/tabular/interfaces.py
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/subformtable.pt
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/subformtable.pt 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/subformtable.pt 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,30 +1,30 @@
-<div metal:define-macro="z3c-tabular-subformtable"
- metal:extend-macro="macro:form">
- <div metal:fill-slot="main">
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td valign="top"
- tal:define="batch view/renderBatch">
- <div>
- <tal:block replace="structure view/renderTable">
- table
- </tal:block>
- </div>
- <div class="batch" tal:condition="batch">
- <tal:block replace="structure batch">
- table
- </tal:block>
- </div>
- </td>
- <td valign="top"
- tal:define="subForm nocall:view/subForm">
- <div class="tableForm" tal:condition="nocall:subForm">
- <tal:block replace="structure subForm/render">
- form
- </tal:block>
- </div>
- </td>
- </tr>
- </table>
- </div>
-</div>
+<div metal:define-macro="z3c-tabular-subformtable"
+ metal:extend-macro="macro:form">
+ <div metal:fill-slot="main">
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td valign="top"
+ tal:define="batch view/renderBatch">
+ <div>
+ <tal:block replace="structure view/renderTable">
+ table
+ </tal:block>
+ </div>
+ <div class="batch" tal:condition="batch">
+ <tal:block replace="structure batch">
+ table
+ </tal:block>
+ </div>
+ </td>
+ <td valign="top"
+ tal:define="subForm nocall:view/subForm">
+ <div class="tableForm" tal:condition="nocall:subForm">
+ <tal:block replace="structure subForm/render">
+ form
+ </tal:block>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+</div>
Property changes on: z3c.tabular/trunk/src/z3c/tabular/subformtable.pt
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/table.pt
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/table.pt 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/table.pt 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,16 +1,16 @@
-<div metal:define-macro="z3c-tabular-table"
- metal:extend-macro="macro:form">
- <div metal:fill-slot="main"
- tal:define="batch view/renderBatch">
- <div class="tabluarTable">
- <tal:block replace="structure view/renderTable">
- table
- </tal:block>
- </div>
- <div class="batch" tal:condition="batch">
- <tal:block replace="structure batch">
- table
- </tal:block>
- </div>
- </div>
-</div>
+<div metal:define-macro="z3c-tabular-table"
+ metal:extend-macro="macro:form">
+ <div metal:fill-slot="main"
+ tal:define="batch view/renderBatch">
+ <div class="tabluarTable">
+ <tal:block replace="structure view/renderTable">
+ table
+ </tal:block>
+ </div>
+ <div class="batch" tal:condition="batch">
+ <tal:block replace="structure batch">
+ table
+ </tal:block>
+ </div>
+ </div>
+</div>
Property changes on: z3c.tabular/trunk/src/z3c/tabular/table.pt
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/table.py
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/table.py 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/table.py 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,258 +1,258 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id:$
-"""
-__docformat__ = "reStructuredText"
-
-import transaction
-import zope.interface
-import zope.i18nmessageid
-
-from z3c.form import button
-from z3c.formui import form
-from z3c.table import table
-from z3c.template.template import getPageTemplate
-
-from z3c.tabular import interfaces
-
-_ = zope.i18nmessageid.MessageFactory('z3c')
-
-
-# simple template rendering aware table base class
-class TemplateTable(table.Table):
- """Template aware teble."""
-
- zope.interface.implements(interfaces.ITemplateTable)
-
- template = getPageTemplate()
-
- def render(self):
- """Render the template."""
- return self.template()
-
-
-# simple form aware table base class
-class TableBase(TemplateTable):
- """Generic table class with form action support used as form mixin base.
-
- This table base class allows you to mixin custom forms as base.
- """
-
- prefix = 'formTable'
-
- # internal defaults
- actions = None
- hasContent = False
- nextURL = None
- selectedItems = []
- ignoreContext = False
-
- # table defaults
- cssClasses = {'table': 'contents'}
- cssClassEven = u'even'
- cssClassOdd = u'odd'
- cssClassSelected = u'selected'
-
- batchSize = 25
- startBatchingAt = 25
-
- # customize this part
- allowCancel = True
- supportsCancel = False
-
- def update(self):
- # 1. setup widgets
- self.updateWidgets()
- # 2. setup search values, generate rows, setup headers and columns
- super(TableBase, self).update()
- # 3. setup conditions
- self.setupConditions()
- # 4. setup form part
- self.updateActions()
- if self.actions is not None:
- self.actions.execute()
-
- def setupConditions(self):
- self.hasContent = bool(self.rows)
- if self.allowCancel:
- self.supportsCancel = self.hasContent
-
- def updateAfterActionExecution(self):
- """Update table data if subform changes soemthing."""
- # first update table data which probably changed
- super(TableBase, self).update()
- # second setup conditions
- self.setupConditions()
- # third update action which we have probably different conditions for
- self.updateActions()
-
- @button.buttonAndHandler(_('Cancel'), name='cancel',
- condition=lambda form:form.supportsCancel)
- def handleCancel(self, action):
- self.nextURL = self.request.getURL()
-
- def render(self):
- """Render the template."""
- if self.nextURL is not None:
- self.request.response.redirect(self.nextURL)
- return ""
- return self.template()
-
-
-class FormTable(TableBase, form.Form):
- """Generic table class with form action support based on IForm."""
-
- zope.interface.implements(interfaces.IFormTable)
-
- template = getPageTemplate()
-
-
-class DeleteFormTable(FormTable):
- """Table class with form action support based on IForm."""
-
- zope.interface.implements(interfaces.IDeleteFormTable)
-
- prefix = 'deleteFormTable'
-
- # internal defaults
- supportsCancel = False
- supportsDelete = False
-
- deleteErrorMessage = _('Could not delete the selected items')
- deleteNoItemsMessage = _('No items selected for delete')
- deleteSuccessMessage = _('Data successfully deleted')
-
- # customize this part
- allowCancel = True
- allowDelete = True
-
- def executeDelete(self, item):
- raise NotImplementedError('Subclass must implement executeDelete')
-
- def setupConditions(self):
- self.hasContent = bool(self.rows)
- if self.allowCancel:
- self.supportsCancel = self.hasContent
- if self.allowDelete:
- self.supportsDelete = self.hasContent
-
- def doDelete(self, action):
- if not len(self.selectedItems):
- self.status = self.deleteNoItemsMessage
- return
- try:
- for item in self.selectedItems:
- self.executeDelete(item)
- # update the table rows before we start with rendering
- self.updateAfterActionExecution()
- if self.status is None:
- # probably execute delete or updateAfterAction already set a
- # status
- self.status = self.deleteSuccessMessage
- except KeyError:
- self.status = self.deleteErrorMessage
- transaction.doom()
-
- @button.buttonAndHandler(_('Delete'), name='delete',
- condition=lambda form:form.supportsDelete)
- def handleDelete(self, action):
- self.doDelete(action)
-
-
-# form table including a sub form
-class SubFormTable(DeleteFormTable):
- """Form table including a sub form based on IForm."""
-
- zope.interface.implements(interfaces.ISubFormTable)
-
- buttons = DeleteFormTable.buttons.copy()
- handlers = DeleteFormTable.handlers.copy()
-
- prefix = 'subFormTable'
-
- # internal defaults
- subForm = None
- supportsEdit = False
-
- # error messages
- subFormNoItemMessage = _('No item selected for edit')
- subFormToManyItemsMessage = _('Only one item could be selected for edit')
- subFormNotFoundMessage = _('No edit form found for selected item')
-
- # customize this part
- # use subFormClass or use subFormName. If you set both it will end in
- # using subFormClass. See updateSubForm for details.
- subFormClass = None
- subFormName = u''
- allowEdit = True
-
- def update(self):
- # 1. setup widgets
- super(SubFormTable, self).update()
- # 2. setup form after we set probably a selectedItem
- self.updateSubForm()
-
- def setupConditions(self):
- super(SubFormTable, self).setupConditions()
- if self.allowEdit:
- self.supportsEdit = self.hasContent
-
- @property
- def selectedItem(self):
- if len(self.selectedItems) == 0:
- return None
- if len(self.selectedItems) > 1:
- self.status = self.subFormToManyItemsMessage
- return None
- return self.selectedItems[0]
-
- def setUpSubForm(self, selectedItem):
- if self.subFormClass is not None:
- return self.subFormClass(selectedItem, self.request)
- elif self.subFormName is not None:
- return zope.component.queryMultiAdapter((selectedItem,
- self.request), name=self.subFormName)
-
- def updateSubForm(self):
- if not self.supportsEdit:
- return
- selectedItem = self.selectedItem
- if selectedItem is None:
- return
- # set table as parent
- self.subForm = self.setUpSubForm(selectedItem)
- if self.subForm is None:
- self.status = self.subFormNotFoundMessage
- return
- self.subForm.__parent__ = self
- # udpate edit form
- self.subForm.update()
-
- def doSubForm(self, action):
- if self.subForm is None:
- return
- # set ignore request and update again
- self.subForm.ignoreRequest = True
- self.subForm.update()
-
- @button.buttonAndHandler(u'Edit', condition=lambda form:form.supportsEdit)
- def handleSubForm(self, action):
- self.updateSubForm()
- self.doSubForm(action)
-
- @button.buttonAndHandler(_('Cancel'), name='cancel',
- condition=lambda form:form.supportsCancel)
- def handleCancel(self, action):
- self.nextURL = self.request.getURL()
+##############################################################################
+#
+# Copyright (c) 2008 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+import transaction
+import zope.interface
+import zope.i18nmessageid
+
+from z3c.form import button
+from z3c.formui import form
+from z3c.table import table
+from z3c.template.template import getPageTemplate
+
+from z3c.tabular import interfaces
+
+_ = zope.i18nmessageid.MessageFactory('z3c')
+
+
+# simple template rendering aware table base class
+class TemplateTable(table.Table):
+ """Template aware teble."""
+
+ zope.interface.implements(interfaces.ITemplateTable)
+
+ template = getPageTemplate()
+
+ def render(self):
+ """Render the template."""
+ return self.template()
+
+
+# simple form aware table base class
+class TableBase(TemplateTable):
+ """Generic table class with form action support used as form mixin base.
+
+ This table base class allows you to mixin custom forms as base.
+ """
+
+ prefix = 'formTable'
+
+ # internal defaults
+ actions = None
+ hasContent = False
+ nextURL = None
+ selectedItems = []
+ ignoreContext = False
+
+ # table defaults
+ cssClasses = {'table': 'contents'}
+ cssClassEven = u'even'
+ cssClassOdd = u'odd'
+ cssClassSelected = u'selected'
+
+ batchSize = 25
+ startBatchingAt = 25
+
+ # customize this part
+ allowCancel = True
+ supportsCancel = False
+
+ def update(self):
+ # 1. setup widgets
+ self.updateWidgets()
+ # 2. setup search values, generate rows, setup headers and columns
+ super(TableBase, self).update()
+ # 3. setup conditions
+ self.setupConditions()
+ # 4. setup form part
+ self.updateActions()
+ if self.actions is not None:
+ self.actions.execute()
+
+ def setupConditions(self):
+ self.hasContent = bool(self.rows)
+ if self.allowCancel:
+ self.supportsCancel = self.hasContent
+
+ def updateAfterActionExecution(self):
+ """Update table data if subform changes soemthing."""
+ # first update table data which probably changed
+ super(TableBase, self).update()
+ # second setup conditions
+ self.setupConditions()
+ # third update action which we have probably different conditions for
+ self.updateActions()
+
+ @button.buttonAndHandler(_('Cancel'), name='cancel',
+ condition=lambda form:form.supportsCancel)
+ def handleCancel(self, action):
+ self.nextURL = self.request.getURL()
+
+ def render(self):
+ """Render the template."""
+ if self.nextURL is not None:
+ self.request.response.redirect(self.nextURL)
+ return ""
+ return self.template()
+
+
+class FormTable(TableBase, form.Form):
+ """Generic table class with form action support based on IForm."""
+
+ zope.interface.implements(interfaces.IFormTable)
+
+ template = getPageTemplate()
+
+
+class DeleteFormTable(FormTable):
+ """Table class with form action support based on IForm."""
+
+ zope.interface.implements(interfaces.IDeleteFormTable)
+
+ prefix = 'deleteFormTable'
+
+ # internal defaults
+ supportsCancel = False
+ supportsDelete = False
+
+ deleteErrorMessage = _('Could not delete the selected items')
+ deleteNoItemsMessage = _('No items selected for delete')
+ deleteSuccessMessage = _('Data successfully deleted')
+
+ # customize this part
+ allowCancel = True
+ allowDelete = True
+
+ def executeDelete(self, item):
+ raise NotImplementedError('Subclass must implement executeDelete')
+
+ def setupConditions(self):
+ self.hasContent = bool(self.rows)
+ if self.allowCancel:
+ self.supportsCancel = self.hasContent
+ if self.allowDelete:
+ self.supportsDelete = self.hasContent
+
+ def doDelete(self, action):
+ if not len(self.selectedItems):
+ self.status = self.deleteNoItemsMessage
+ return
+ try:
+ for item in self.selectedItems:
+ self.executeDelete(item)
+ # update the table rows before we start with rendering
+ self.updateAfterActionExecution()
+ if self.status is None:
+ # probably execute delete or updateAfterAction already set a
+ # status
+ self.status = self.deleteSuccessMessage
+ except KeyError:
+ self.status = self.deleteErrorMessage
+ transaction.doom()
+
+ @button.buttonAndHandler(_('Delete'), name='delete',
+ condition=lambda form:form.supportsDelete)
+ def handleDelete(self, action):
+ self.doDelete(action)
+
+
+# form table including a sub form
+class SubFormTable(DeleteFormTable):
+ """Form table including a sub form based on IForm."""
+
+ zope.interface.implements(interfaces.ISubFormTable)
+
+ buttons = DeleteFormTable.buttons.copy()
+ handlers = DeleteFormTable.handlers.copy()
+
+ prefix = 'subFormTable'
+
+ # internal defaults
+ subForm = None
+ supportsEdit = False
+
+ # error messages
+ subFormNoItemMessage = _('No item selected for edit')
+ subFormToManyItemsMessage = _('Only one item could be selected for edit')
+ subFormNotFoundMessage = _('No edit form found for selected item')
+
+ # customize this part
+ # use subFormClass or use subFormName. If you set both it will end in
+ # using subFormClass. See updateSubForm for details.
+ subFormClass = None
+ subFormName = u''
+ allowEdit = True
+
+ def update(self):
+ # 1. setup widgets
+ super(SubFormTable, self).update()
+ # 2. setup form after we set probably a selectedItem
+ self.updateSubForm()
+
+ def setupConditions(self):
+ super(SubFormTable, self).setupConditions()
+ if self.allowEdit:
+ self.supportsEdit = self.hasContent
+
+ @property
+ def selectedItem(self):
+ if len(self.selectedItems) == 0:
+ return None
+ if len(self.selectedItems) > 1:
+ self.status = self.subFormToManyItemsMessage
+ return None
+ return self.selectedItems[0]
+
+ def setUpSubForm(self, selectedItem):
+ if self.subFormClass is not None:
+ return self.subFormClass(selectedItem, self.request)
+ elif self.subFormName is not None:
+ return zope.component.queryMultiAdapter((selectedItem,
+ self.request), name=self.subFormName)
+
+ def updateSubForm(self):
+ if not self.supportsEdit:
+ return
+ selectedItem = self.selectedItem
+ if selectedItem is None:
+ return
+ # set table as parent
+ self.subForm = self.setUpSubForm(selectedItem)
+ if self.subForm is None:
+ self.status = self.subFormNotFoundMessage
+ return
+ self.subForm.__parent__ = self
+ # udpate edit form
+ self.subForm.update()
+
+ def doSubForm(self, action):
+ if self.subForm is None:
+ return
+ # set ignore request and update again
+ self.subForm.ignoreRequest = True
+ self.subForm.update()
+
+ @button.buttonAndHandler(u'Edit', condition=lambda form:form.supportsEdit)
+ def handleSubForm(self, action):
+ self.updateSubForm()
+ self.doSubForm(action)
+
+ @button.buttonAndHandler(_('Cancel'), name='cancel',
+ condition=lambda form:form.supportsCancel)
+ def handleCancel(self, action):
+ self.nextURL = self.request.getURL()
Property changes on: z3c.tabular/trunk/src/z3c/tabular/table.py
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/testing.py
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/testing.py 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/testing.py 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,40 +1,40 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id:$
-"""
-__docformat__ = "reStructuredText"
-
-from zope.browserpage import metaconfigure
-from zope.app.testing import setup
-
-import z3c.macro.tales
-import z3c.table.testing
-
-
-###############################################################################
-#
-# testing setup
-#
-###############################################################################
-
-def setUp(test):
- test.globs = {'root': setup.placefulSetUp(True)}
-
- metaconfigure.registerType('macro', z3c.macro.tales.MacroExpression)
- z3c.table.testing.setUpAdapters()
-
-
-def tearDown(test):
- setup.placefulTearDown()
+##############################################################################
+#
+# Copyright (c) 2008 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+from zope.browserpage import metaconfigure
+from zope.app.testing import setup
+
+import z3c.macro.tales
+import z3c.table.testing
+
+
+###############################################################################
+#
+# testing setup
+#
+###############################################################################
+
+def setUp(test):
+ test.globs = {'root': setup.placefulSetUp(True)}
+
+ metaconfigure.registerType('macro', z3c.macro.tales.MacroExpression)
+ z3c.table.testing.setUpAdapters()
+
+
+def tearDown(test):
+ setup.placefulTearDown()
Property changes on: z3c.tabular/trunk/src/z3c/tabular/testing.py
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: z3c.tabular/trunk/src/z3c/tabular/tests.py
===================================================================
--- z3c.tabular/trunk/src/z3c/tabular/tests.py 2013-02-26 17:50:03 UTC (rev 129854)
+++ z3c.tabular/trunk/src/z3c/tabular/tests.py 2013-02-26 17:51:39 UTC (rev 129855)
@@ -1,66 +1,66 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id:$
-"""
-__docformat__ = "reStructuredText"
-
-import unittest
-import doctest
-from zope.publisher.browser import TestRequest
-
-import z3c.testing
-import z3c.table.testing
-from z3c.tabular import interfaces
-from z3c.tabular import table
-from z3c.tabular import testing
-
-
-class FakeContainer(object):
- def values(self):
- pass
-
-
-# table
-class TestFormTable(z3c.testing.InterfaceBaseTest):
-
- def setUp(test):
- z3c.table.testing.setUpAdapters()
-
- def getTestInterface(self):
- return interfaces.IFormTable
-
- def getTestClass(self):
- return table.FormTable
-
- def getTestPos(self):
- return (FakeContainer(), TestRequest())
-
-
-
-def test_suite():
- optionflags = (doctest.NORMALIZE_WHITESPACE
- |doctest.ELLIPSIS
- |doctest.REPORT_NDIFF)
- return unittest.TestSuite((
- doctest.DocFileSuite('README.txt',
- setUp=testing.setUp, tearDown=testing.tearDown,
- optionflags=optionflags,
- ),
- unittest.makeSuite(TestFormTable),
- ))
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+##############################################################################
+#
+# Copyright (c) 2008 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest
+import doctest
+from zope.publisher.browser import TestRequest
+
+import z3c.testing
+import z3c.table.testing
+from z3c.tabular import interfaces
+from z3c.tabular import table
+from z3c.tabular import testing
+
+
+class FakeContainer(object):
+ def values(self):
+ pass
+
+
+# table
+class TestFormTable(z3c.testing.InterfaceBaseTest):
+
+ def setUp(test):
+ z3c.table.testing.setUpAdapters()
+
+ def getTestInterface(self):
+ return interfaces.IFormTable
+
+ def getTestClass(self):
+ return table.FormTable
+
+ def getTestPos(self):
+ return (FakeContainer(), TestRequest())
+
+
+
+def test_suite():
+ optionflags = (doctest.NORMALIZE_WHITESPACE
+ |doctest.ELLIPSIS
+ |doctest.REPORT_NDIFF)
+ return unittest.TestSuite((
+ doctest.DocFileSuite('README.txt',
+ setUp=testing.setUp, tearDown=testing.tearDown,
+ optionflags=optionflags,
+ ),
+ unittest.makeSuite(TestFormTable),
+ ))
+
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: z3c.tabular/trunk/src/z3c/tabular/tests.py
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the checkins
mailing list