[Product-Developers] Problem creating first product

Eric W. Bates ericx at vineyard.net
Mon May 19 12:56:11 UTC 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Andreas Jung wrote:
|
|
| --On 18. Mai 2008 20:54:29 -0700 ericx <ericx at vineyard.net> wrote:
|
|>> Test-module import failures:
|>
|> Module: hhsa.policy.tests
|>
|> AttributeError: 'module' object has no attribute 'test_suite'
|
| This say it all. Aside from that there is little we can do because
| your posting does not contain much useable in order for giving further
| help. So first trible check your code (look at your error message, you
| need a test_suite() method).

Yah.  That's what I thot too. However, the definition of test_suite()
actually appears twice:

~ ** root at ethel ** /usr/local/www/hhsa ** Mon May 19 08:26:15
# find ./src/ -type f | xargs grep test_suite | grep -v .svn | grep -v pyc
./src/hhsa.policy/hhsa/policy/tests.py:def test_suite():
./src/hhsa.policy/hhsa/policy/tests.py:
unittest.main(defaultTest='test_suite')
./src/hhsa.policy/hhsa/policy/tests/test_setup.py:def test_suite():

It appears first in ./src/hhsa.policy/hhsa/policy/tests.py (a file
created by buildout) and later in ./src/hhsa.policy/hhsa/policy/tests.py
(a file I created as an exercise in the book).

By removing the file created by buildout, I do get rid of the
AttributeError; however, the "NOT FOUND" error remains.

- --

Sorry I didn't supply more initially. I assumed this must be some sort
of obvious newbie mistake.

What would be helpful to see?  The source? To the best of my ability I
believe it is a duplicate of examples given in the book with only a few
name changes. Included below are: buildout.cfg, configure.zcml, base.py,
setup_tests.py, and properties.xml


buildout.cfg

# File:		buildout.cfg
# Author:	Charlie Root, ericx at vineyard.net
# Date:		Wed May 14 21:02:08 2008
# Time-stamp:	<2008-05-16 18:40:03 ericx>
# Description:	The mysterious plone buildout file. Must learn more...
#
# $Id: buildout.cfg 9 2008-05-16 22:52:18Z root $

[buildout]
parts =
~    plone
~    productdistros
~    instance
~    zopepy

# Add additional egg download sources here. dist.plone.org contains archives
# of Plone packages.
find-links =
~    http://dist.plone.org
~    http://download.zope.org/ppix/
~    http://download.zope.org/distribution/
~    http://effbot.org/downloads

# Add additional eggs here
# elementtree is required by Plone
eggs =
~    elementtree
~    hhsa.policy

# Reference any eggs you are developing here, one per line
# e.g.: develop = src/my.package
develop =
~    src/hhsa.policy

[plone]
#recipe = plone.recipe.plone>=3.0,<3.1dev
recipe = plone.recipe.plone==3.0.6
#recipe = plone.recipe.plone>=3.0.6,<3.1dev
# By overriding the download URLs and making them an empty list, we
# Make sure our own products directory takes precedence
urls =


# Use this section to download additional old-style products.
# List any number of URLs for product tarballs under URLs (separate
# with whitespace, or break over several lines, with subsequent lines
# indented). If any archives contain several products inside a top-level
# directory, list the archive file name (i.e. the last part of the URL,
# normally with a .tar.gz suffix or similar) under 'nested-packages'.
# If any archives extract to a product directory with a version suffix, list
# the archive name under 'version-suffix-packages'.
[productdistros]
recipe = plone.recipe.distros
urls =

http://www.zope.org/Members/shh/DocFinderTab/1.0.2/DocFinderTab-1.0.2.tar.gz
~  http://plone.org/products/clouseau/releases/0.8.1/clouseau-0-8-1.zip
nested-packages =
version-suffix-packages =

[instance]
recipe = plone.recipe.zope2instance
zope2-location = /usr/local/www/Zope210
user = zope_admin:zope-pass
http-address = 8080
debug-mode = on
#verbose-security = on

# If you want Zope to know about any additional eggs, list them here.
# This should include any development eggs you listed in develop-eggs above,
# e.g. eggs = ${buildout:eggs} ${plone:eggs} my.package
eggs =
~    ${buildout:eggs}
~    ${plone:eggs}

# If you want to register ZCML slugs for any packages, list them here.
# e.g. zcml = my.package my.other.package
zcml =
~    hhsa.policy

products =
~    ${buildout:directory}/products
~    ${productdistros:location}
~    /usr/local/www/Zope210/Products

zope-conf-additional =
~    effective-user zope

[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
extra-paths = /usr/local/www/Zope210/lib/python
scripts = zopepy



./src/hhsa.policy/hhsa/policy/configure.zcml

<configure
~    xmlns="http://namespaces.zope.org/zope"
~    xmlns:five="http://namespaces.zope.org/five"
~    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
~    i18n_domain="hhsa.policy">

~    <genericsetup:registerProfile
~      name="default"
~      title="HHSA Site Policy"
~      directory="profiles/default"
~      description="Turn a Plone site into the HHSA site."
~      provides="Products.GenericSetup.interfaces.EXTENSION"
~      />

</configure>


./src/hhsa.policy/hhsa/policy/tests/base.py

# File:         base.py
# Author:       Charlie Root, ericx at vineyard.net
# Date:         Fri May 16 20:08:00 2008
# Time-stamp:   <2008-05-16 21:19:15 ericx>
# Description:  tests, wonderful tests...
#
# $Id: base.py 14 2008-05-19 01:07:41Z root $

from Products.Five import zcml
from Products.Five import fiveconfigure

from Testing import ZopeTestCase as ztc

from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup

@onsetup
def setup_hhsa_policy():
~    """Set up the additional products required for the HHSA site
~    policy.

~    The @onsetup decorator causes the execution of this body to be
~    deferred until the setup of the Plone site testing layer.
~    """

~    # Load the ZCML configuration for the hhsa.policy package.

~    fiveconfigure.debug_mode = True
~    import hhsa.policy
~    zcml.load_config('configure.zcml', hhsa.policy)
~    fiveconfigure.debug_mode = False

~    # We need to tell the testing framework that these products should
~    # be available. This can't happen until after we have loaded the
~    # ZCML.

~    ztc.installPackage('hhsa.policy')

# The order here is important: We firs call the (deferred) function
# which installs teh products we need for the HHSA package. Then we
# let PloneTestCase set up this product on installation.
setup_hhsa_policy()
ptc.setupPloneSite(products=['hhsa.policy'])

class HHSAPolicyTestCase(ptc.PloneTestCase):
~    """We use this base class for all the tests in this package. If
~    necessary, we can put common utility or setup code in here.
~    """


./src/hhsa.policy/hhsa/policy/tests/test_setup.py

# File:         test_setup.py
# Author:       Charlie Root, ericx at vineyard.net
# Date:         Fri May 16 20:46:35 2008
# Time-stamp:   <2008-05-18 21:17:58 ericx>
# Description:  testy testy testy
#
# $Id: test_setup.py 15 2008-05-19 01:08:18Z root $

import unittest
from hhsa.policy.tests.base import HHSAPolicyTestCase

class TestSetup(HHSAPolicyTestCase):

~    def test_portal_title(self):
~        self.assertEquals("Holmes Hole Sailing Association",
~                          self.portal.getProperty('title'))

~    def test_portal_description(self):
~        self.assertEquals("Welcome to the HHSA web site.",
~                          self.portal.getProperty('description'))

def test_suite():
~    suite = unittest.TestSuite()
~    suite.addTest(unittest.makeSuite(TestSetup))
~    return suite


./src/hhsa.policy/hhsa/policy/profiles/default/properties.xml

<?xml version="1.0"?>
<!-- $Id: properties.xml 17 2008-05-19 01:24:15Z root $ -->
<site>
~  <property name="title">Holmes Hole Sailing Association</property>
~  <property name="description">Welcome to the HHSA web site.</property>
</site>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIMXjrD1roJTQ4LlERAuTKAJ96QpDqN/92t6eNkDbKUTLHuPx8awCgilMz
NDLhSeqsfhDGjvR/XWXQVoI=
=vlEo
-----END PGP SIGNATURE-----




More information about the Product-Developers mailing list