Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Added Contents class with useful defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
projekt01 committed Apr 7, 2008
1 parent 21d472b commit 1f908cd
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
74 changes: 73 additions & 1 deletion src/z3c/contents/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ And we need to configure our contents.pt template for the ContentsPage:
... <configure
... xmlns:z3c="http://namespaces.zope.org/z3c">
... <z3c:template
... for="z3c.contents.browser.ContentsPage"
... for="z3c.contents.interfaces.IContentsPage"
... template="%s"
... />
... </configure>
Expand Down Expand Up @@ -832,3 +832,75 @@ Batching
--------

TODO: add tests for batching


Contents
--------

There is a ContentsPage with useful defaults. This contents page provides
a CSS class called ``contents`` for the table tag and uses ``even`` and ``odd``
row CSS class markers. The default batch size is set to ``25``:

>>> request = TestRequest()
>>> alsoProvides(request, IDivFormLayer)
>>> contents = browser.Contents(secondContainer, request)
>>> contents.update()
>>> print contents.render()
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="edit-form"
name="contents" id="contents">
<div class="viewspace">
<div class="required-info">
<span class="required">*</span>
&ndash; required
</div>
<div>
<table class="contents">
<thead>
<tr>
<th>X</th>
<th>Name</th>
<th>Created</th>
<th>Modified</th>
</tr>
</thead>
<tbody>
<tr class="even">
<td><input type="checkbox" class="checkbox-widget" name="contents-checkBoxColumn-0-selectedItems" value="fifth" /></td>
<td><a href="http://127.0.0.1/secondContainer/fifth">fifth</a></td>
<td>01/01/01 01:01</td>
<td>02/02/02 02:02</td>
</tr>
<tr class="odd">
<td><input type="checkbox" class="checkbox-widget" name="contents-checkBoxColumn-0-selectedItems" value="first" /></td>
<td><a href="http://127.0.0.1/secondContainer/first">first</a></td>
<td>01/01/01 01:01</td>
<td>02/02/02 02:02</td>
</tr>
<tr class="even">
<td><input type="checkbox" class="checkbox-widget" name="contents-checkBoxColumn-0-selectedItems" value="zero" /></td>
<td><a href="http://127.0.0.1/secondContainer/zero">zero</a></td>
<td>01/01/01 01:01</td>
<td>02/02/02 02:02</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="buttons">
<input type="submit" id="contents-buttons-copy"
name="contents.buttons.copy"
class="submit-widget button-field" value="Copy" />
<input type="submit" id="contents-buttons-cut"
name="contents.buttons.cut"
class="submit-widget button-field" value="Cut" />
<input type="submit" id="contents-buttons-delete"
name="contents.buttons.delete"
class="submit-widget button-field" value="Delete" />
<input type="submit" id="contents-buttons-rename"
name="contents.buttons.rename"
class="submit-widget button-field" value="Rename" />
</div>
</div>
</form>
13 changes: 13 additions & 0 deletions src/z3c/contents/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,16 @@ def handlerRename(self, action):
renameCol = self.columnByName.get('renameColumn')
if renameCol:
renameCol.errorMessages = errorMessages


class Contents(ContentsPage):
"""ContentsPage with useful defaults."""

# contents defaults
cssClasses = {'table': 'contents'}
cssClassEven = u'even'
cssClassOdd = u'odd'
cssClassSelected = u'selected'

batchSize = 25
startBatchingAt = 25
6 changes: 6 additions & 0 deletions src/z3c/contents/browser.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@
layer="zope.publisher.interfaces.browser.IBrowserRequest"
/>

<z3c:template
template="contents.pt"
for=".browser.Contents"
layer="zope.publisher.interfaces.browser.IBrowserRequest"
/>

</configure>

0 comments on commit 1f908cd

Please sign in to comment.