Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install cornerstone.ui.result

How to install cornerstone.ui.result

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install cornerstone.ui.result
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.1.4 Available View build log
Windows (64-bit)
1.1.4 Available View build log
Mac OS X (10.5+)
1.1.4 Available View build log
Linux (32-bit)
1.1.4 Available View build log
Linux (64-bit)
1.1.4 Available View build log
Web
 
License
License :: OSI Approved :: Zope Public License
Dependencies
Lastest release
version 1.1.4 on Jan 5th, 2011

Overview

This module provides rendering results. The intention was to not write stupid view logic again and again.

The structure of the results is defined via ZCML. To finally make the framework render the result you have to subclass some baseimplementations of the framework providing rendering informations such like batch vocabs, result slices, etc.

At the moment the the framework provides batching and slices, in future it will be extended with features for defining result sorting mechanisms, nested batches, and more detailed slice definitions.

You can find a first example on how to implement results at: https://svn.plone.org/svn/collective/Directory

Each defined result is internal registered as ViewletManager, and will be rendered by calling a contentprovider out of a page template f.e.:

<tal:block tal:replace="structure provider:directory.directorylisting" />

The result definition in zcml looks like this:

<configure xmlns="http://namespaces.zope.org/cornerstone">

<result for="Products.Directory.content.interfaces.IDirectory" class=".browser.directory.DirectoryListingResult" permission="zope.Public" name="directory.directorylisting" threshold="0">

<batch domain="directorybatch" vocab=".browser.directory.DirectoryBatchVocab" />

<slice class=".browser.directory.DirectoryListingSlice" name="directoryslice" template="templates/directory_listing.pt" allowed_interface="Products.Directory.browser.interfaces.IDirectoryListing" />

<batch domain="directorybatch" />

</result>

</configure>

Consider that if you want to render the same batch twice, f.e. above and below the slice, you only have to define the batch definitions once and can add it a second time simply by defining the batch domain.

A result can have the following attributes:
  • for="*" (the interface the result is bound to)
  • class=".env.TestResult" (the class providing the results itself)
  • permission="zope.Public" (the permission to view the result)
  • name='testresult' (the name under which the result can be called as

System Message: WARNING/2 (<string>, line 68)

Bullet list ends without a blank line; unexpected unindent.

contentprovider)

  • slicesize="20" (the size of the result slice, optional)
  • threshold="20" (the threshold how many results are required to display

System Message: WARNING/2 (<string>, line 73)

Bullet list ends without a blank line; unexpected unindent.

batches, optional)

A Batch can have the following attributes:
  • domain="testbatch" (the domain of this batch. this is used to differ the

System Message: WARNING/2 (<string>, line 80)

Bullet list ends without a blank line; unexpected unindent.

batch from perhaps other rendered batches on the same page)

  • vocab=".env.TestBatchVocab" (the class providing the batch vocab)
  • template="templates/batch.pt" (the template used to render the batch,

System Message: WARNING/2 (<string>, line 85)

Bullet list ends without a blank line; unexpected unindent.

optional)

  • firstpagelink="True" (flag wether to display the firstpagelink or not,

System Message: WARNING/2 (<string>, line 88)

Bullet list ends without a blank line; unexpected unindent.

optional)

  • lastpagelink="True" (flag wether to display the lastpagelink or not,

System Message: WARNING/2 (<string>, line 91)

Bullet list ends without a blank line; unexpected unindent.

optional)

  • prevpagelink="True" (flag wether to display the prevpagelink or not,

System Message: WARNING/2 (<string>, line 94)

Bullet list ends without a blank line; unexpected unindent.

optional)

  • nextpagelink="True" (flag wether to display the nextpagelink or not,

System Message: WARNING/2 (<string>, line 97)

Bullet list ends without a blank line; unexpected unindent.

optional)

  • batchrange="30" (the batchrange. defines how many pages are displayed,

System Message: WARNING/2 (<string>, line 100)

Bullet list ends without a blank line; unexpected unindent.

f.e. "<< < ... 5 6 7 8 ... > >>", optional)

  • masters="anotherbatchdomain" (Batch(es) the defined batch depends on, the

System Message: WARNING/2 (<string>, line 103)

Bullet list ends without a blank line; unexpected unindent.

value must be the domain of the batch(es) you want to consider)

  • title="The Title" (An optional title to label the batch)
  • forcedisplay="True" (An optional flag wether to force batch displaying

System Message: WARNING/2 (<string>, line 108)

Bullet list ends without a blank line; unexpected unindent.

or not)

  • querywhitelist="sort" (Query Params to be considered when generating

System Message: WARNING/2 (<string>, line 111)

Bullet list ends without a blank line; unexpected unindent.

urls. This is needed if you have to use some additional params in the slice)

The slice definitions are treated as viewlet definitions and therefor follow
the viewlet definition rules:
  • class=".browser.directory.DirectoryListingSlice"
  • name="directoryslice"
  • template="templates/directory_listing.pt"
  • allowed_interface="Products.Directory.browser.interfaces.IDirectoryListing"
The example pointed above implements an alphabatched directory listing and
subclasses therfor this objects:
  • cornerstone.ui.result.result.ResultBase
  • cornerstone.ui.result.batch.AlphaBatchVocabBase
  • cornerstone.ui.result.slice.AlphaBatchedSliceBase

The result class:

System Message: WARNING/2 (<string>, line 143)

Literal block expected; none found.

class DirectoryListingResult(ResultBase):

name = 'directory.directorylisting'

@property def results(self): return self._getEntries({ 'meta_type': 'DirectoryEntry', 'path': '/'.join(self.context.getPhysicalPath()), })

def _getEntries(self, query): catalog = getToolByName(self.context, 'membrane_tool') brains = catalog(**query) entries = [] for brain in brains: entry = dict() entry['name'] = brain.Title entry['email'] = brain.getEmail entry['url'] = brain.getURL() entry['review_state'] = brain.review_state entries.append(entry) return entries

System Message: WARNING/2 (<string>, line 154); backlink

Inline strong start-string without end-string.

Consider:

  • since there is no senceful way to determine the name under which a

System Message: WARNING/2 (<string>, line 172)

Bullet list ends without a blank line; unexpected unindent.

specific ViewletManager is registered out of itself you must provide the name attribute.

  • further you have to provide the results. in the example above it is a

System Message: WARNING/2 (<string>, line 176)

Bullet list ends without a blank line; unexpected unindent.

list of dictionaries. of course this is the format (list of dicts) the framework can handle well at the moment. in future there will be also base implementations be able to handle catalog brains.

  • the result implementing class is used by the other needed classes to

System Message: WARNING/2 (<string>, line 181)

Bullet list ends without a blank line; unexpected unindent.

extract the batch informations and the slice informations

The batch vocab class:

# pages definitions will be looked up by an adapter in future

System Message: ERROR/3 (<string>, line 187)

Inconsistent literal block quoting.

pages = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ]

class DirectoryBatchVocab(AlphaBatchVocabBase):

@property def vocab(self): visibles = self.getVisiblesFromDictList('name') return self.generateVocab(visibles, pages)

Consider:

  • The base class AlphaBatchVocabBase can handle results which are a list

System Message: WARNING/2 (<string>, line 204)

Bullet list ends without a blank line; unexpected unindent.

of dicts and does most of the work for you. As written earlier there should be also a base implementation for handling brain based result lists.

  • the page list is needed to calculate an alphabatch

System Message: WARNING/2 (<string>, line 209)

Bullet list ends without a blank line; unexpected unindent.

(it is not necessary for numeric batches) and must be available in the class defining the batch vocab and the result slice itself, see below. This should be looked up by an interface in future

The slice class:

System Message: WARNING/2 (<string>, line 216)

Literal block expected; none found.

class DirectoryListingSlice(AlphaBatchedSliceBase):

@property def entries(self): key = 'name' batchname = 'directorybatch' self.pages = pages self.sortResults(key) current = self.determineCurrentPage(batchname, key) return self.generateCurrentSlice(current, key)

Enable KSS:

KSS is enabled by defult when applying the extension profile.

To enable kss for anonymous users too, you have to change the condition of kukit.js in the portal_javascripts resource registry.

Consider:

  • In this subclass the same rules for results applies as for the batch

System Message: WARNING/2 (<string>, line 241)

Bullet list ends without a blank line; unexpected unindent.

vocab base class.

  • you have to provide the batchname this slice is used for
  • the pages global is here used too. see statement why framework is alpha

System Message: WARNING/2 (<string>, line 246)

Bullet list ends without a blank line; unexpected unindent.

state.

Credits:

  • This library is an outcome of the UN ILO Better Work project.
  • Written by Robert Niederreiter <rnix@squarewave.at>,

System Message: WARNING/2 (<string>, line 255)

Bullet list ends without a blank line; unexpected unindent.

Squarewave Computing, Austia - Blue Dynamics Alliance

System Message: WARNING/2 (<string>, line 258)

Bullet list ends without a blank line; unexpected unindent.

design ideas

System Message: WARNING/2 (<string>, line 263)

Bullet list ends without a blank line; unexpected unindent.

implementation and testing

Changes

1.1.4 (svn)
  • fix numeric slice default page

System Message: WARNING/2 (<string>, line 273)

Bullet list ends without a blank line; unexpected unindent.

(rnix, 2010-06-16)

1.1.3
  • make alpha batch non-ascii aware

System Message: WARNING/2 (<string>, line 279)

Bullet list ends without a blank line; unexpected unindent.

(rnix, 2010-06-15)

1.1.2
  • make value of request param unicode aware in batch.py

System Message: WARNING/2 (<string>, line 285)

Bullet list ends without a blank line; unexpected unindent.

(rnix, 2010-04-13)

1.1.1
  • Write url query data to self.request.form instead of self.request in KSS

System Message: WARNING/2 (<string>, line 291)

Bullet list ends without a blank line; unexpected unindent.

view (rnix, 2009-03-25)

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.