[Checkins] SVN: z3c.viewlet/trunk/ - Create good package setup.

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Oct 30 17:06:43 EDT 2007


Log message for revision 81236:
  - Create good package setup.
  
  - Added tests.
  

Changed:
  _U  z3c.viewlet/trunk/
  A   z3c.viewlet/trunk/CHANGES.txt
  U   z3c.viewlet/trunk/README.txt
  A   z3c.viewlet/trunk/bootstrap.py
  A   z3c.viewlet/trunk/buildout.cfg
  D   z3c.viewlet/trunk/setup.cfg
  U   z3c.viewlet/trunk/setup.py
  _U  z3c.viewlet/trunk/src/
  A   z3c.viewlet/trunk/src/z3c/viewlet/README.txt
  A   z3c.viewlet/trunk/src/z3c/viewlet/tests.py

-=-

Property changes on: z3c.viewlet/trunk
___________________________________________________________________
Name: svn:ignore
   - build
dist

   + .installed.cfg
bin
build
develop-eggs
dist
parts


Added: z3c.viewlet/trunk/CHANGES.txt
===================================================================
--- z3c.viewlet/trunk/CHANGES.txt	                        (rev 0)
+++ z3c.viewlet/trunk/CHANGES.txt	2007-10-30 21:06:42 UTC (rev 81236)
@@ -0,0 +1,10 @@
+=======
+CHANGES
+=======
+
+1.0.0 (2007-10-30)
+------------------
+
+- Initial release.
+
+  * Weight-ordered viewlet manager.


Property changes on: z3c.viewlet/trunk/CHANGES.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: z3c.viewlet/trunk/README.txt
===================================================================
--- z3c.viewlet/trunk/README.txt	2007-10-30 20:36:55 UTC (rev 81235)
+++ z3c.viewlet/trunk/README.txt	2007-10-30 21:06:42 UTC (rev 81236)
@@ -1 +1,2 @@
-The z3c.viewlet package provides an weight ordered viewlet manager.
+This package is a collection of viewlet extensions; see ``zope.viewlet`` for
+more information.

Added: z3c.viewlet/trunk/bootstrap.py
===================================================================
--- z3c.viewlet/trunk/bootstrap.py	                        (rev 0)
+++ z3c.viewlet/trunk/bootstrap.py	2007-10-30 21:06:42 UTC (rev 81236)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                     ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+    cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, sys.executable,
+    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)


Property changes on: z3c.viewlet/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: z3c.viewlet/trunk/buildout.cfg
===================================================================
--- z3c.viewlet/trunk/buildout.cfg	                        (rev 0)
+++ z3c.viewlet/trunk/buildout.cfg	2007-10-30 21:06:42 UTC (rev 81236)
@@ -0,0 +1,7 @@
+[buildout]
+develop = .
+parts = test
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.viewlet

Deleted: z3c.viewlet/trunk/setup.cfg
===================================================================
--- z3c.viewlet/trunk/setup.cfg	2007-10-30 20:36:55 UTC (rev 81235)
+++ z3c.viewlet/trunk/setup.cfg	2007-10-30 21:06:42 UTC (rev 81236)
@@ -1,3 +0,0 @@
-[egg_info]
-tag_build = .dev
-tag_svn_revision = 1

Modified: z3c.viewlet/trunk/setup.py
===================================================================
--- z3c.viewlet/trunk/setup.py	2007-10-30 20:36:55 UTC (rev 81235)
+++ z3c.viewlet/trunk/setup.py	2007-10-30 21:06:42 UTC (rev 81236)
@@ -1,20 +1,60 @@
-#!python
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+"""Setup for z3c.viewlet package
+
+$Id: setup.py 81038 2007-10-24 14:34:17Z srichter $
+"""
+import os
 from setuptools import setup, find_packages
 
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
 setup(name='z3c.viewlet',
-      version='0.1.0',
-      author = "Zope Community",
-      author_email = "zope3-dev at zope.org",
-      description = open("README.txt").read(),
-      license = "ZPL 2.1",
-      keywords = "viewlet zope zope3",
-      url='http://svn.zope.org/z3c.viewlet',
-
-      zip_safe=False,
+      version = '1.0.0',
+      author='Zope Corporation and Contributors',
+      author_email='zope3-dev at zope.org',
+      description='Collection of Viewlet Extensions',
+      long_description=(
+          read('README.txt')
+          + '\n\n' +
+          'Detailed Dcoumentation\n' +
+          '======================\n'
+          + '\n\n' +
+          read('src', 'z3c', 'viewlet', 'README.txt')
+          + '\n\n' +
+          read('CHANGES.txt')
+          ),
+      keywords = "zope3 viewlet extension weight ordered",
+      classifiers = [
+          'Development Status :: 5 - Production/Stable',
+          'Environment :: Web Environment',
+          'Intended Audience :: Developers',
+          'License :: OSI Approved :: Zope Public License',
+          'Programming Language :: Python',
+          'Natural Language :: English',
+          'Operating System :: OS Independent',
+          'Topic :: Internet :: WWW/HTTP',
+          'Framework :: Zope3'],
+      url='http://cheeseshop.python.org/pypi/z3c.viewlet',
+      license='ZPL 2.1',
       packages=find_packages('src'),
-      include_package_data=True,
-      package_dir = {'':'src'},
-      namespace_packages=['z3c',],
-      install_requires=['setuptools', 'zope.viewlet'],
-     )
-
+      package_dir = {'': 'src'},
+      namespace_packages=['z3c'],
+      extras_require=dict(test=['zope.testing']),
+      install_requires=['setuptools',
+                        'zope.viewlet'],
+      include_package_data = True,
+      zip_safe = False,
+      )


Property changes on: z3c.viewlet/trunk/src
___________________________________________________________________
Name: svn:ignore
   + z3c.viewlet.egg-info


Added: z3c.viewlet/trunk/src/z3c/viewlet/README.txt
===================================================================
--- z3c.viewlet/trunk/src/z3c/viewlet/README.txt	                        (rev 0)
+++ z3c.viewlet/trunk/src/z3c/viewlet/README.txt	2007-10-30 21:06:42 UTC (rev 81236)
@@ -0,0 +1,68 @@
+==================
+Viewlet Extensions
+==================
+
+This package provides extensions to the basic ``zope.viewlet`` package
+functionality.
+
+
+Weight-Ordered Viewlet Manager
+------------------------------
+
+The viewlet manager in ``zope.viewlet`` does not implement a particular way of
+sorting the viewlets it represents. This was intentional, since the authors
+did not want to suggest a particular method of sorting viewlets. Over time,
+however, it turns out that sorting viewlets by a relative weight is very
+useful and sufficient for most situations.
+
+  >>> from z3c.viewlet import manager
+
+Every viewlet displayed by a weight-ordered viewlet manager is expected to
+have a ``weight`` attribute that is an integer; it can also be a string that
+can be converted to an integer. If a viewlet does not have this attribute, a
+weight of zero is assumed.
+
+The manager uses a helper function to extract the weight. So let's create a
+dummy viewlet:
+
+  >>> class Viewlet(object):
+  ...   pass
+
+  >>> viewlet = Viewlet()
+
+Initially, there is no weight attribute, so the weight is zero.
+
+  >>> manager.getWeight(('viewlet', viewlet))
+  0
+
+If the viewlet has a weight, ...
+
+  >>> viewlet.weight = 1
+
+... it is returned:
+
+  >>> manager.getWeight(('viewlet', viewlet))
+  1
+
+As mentioned before, the weight can also be a string representation of an
+integer:
+
+  >>> viewlet.weight = '2'
+  >>> manager.getWeight(('viewlet', viewlet))
+  2
+
+Let's now check that the sorting works correctly for the manager:
+
+  >>> zero = Viewlet()
+
+  >>> one = Viewlet()
+  >>> one.weight = 1
+
+  >>> two = Viewlet()
+  >>> two.weight = '2'
+
+  >>> viewlets = manager.WeightOrderedViewletManager(None, None, None)
+  >>> viewlets.sort([ ('zero', zero), ('one', one), ('two', two) ])
+  [('zero', <Viewlet object at ...>),
+   ('one', <Viewlet object at ...>),
+   ('two', <Viewlet object at ...>)]


Property changes on: z3c.viewlet/trunk/src/z3c/viewlet/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.viewlet/trunk/src/z3c/viewlet/tests.py
===================================================================
--- z3c.viewlet/trunk/src/z3c/viewlet/tests.py	                        (rev 0)
+++ z3c.viewlet/trunk/src/z3c/viewlet/tests.py	2007-10-30 21:06:42 UTC (rev 81236)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+"""Currency Test Setup
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest
+from zope.testing import doctest
+from zope.testing.doctestunit import DocFileSuite
+
+def test_suite():
+    return unittest.TestSuite((
+        DocFileSuite('README.txt',
+                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+                     ),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')


Property changes on: z3c.viewlet/trunk/src/z3c/viewlet/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Checkins mailing list