示例#1
0
class test_BooleanVar(unittest.TestCase):
    """ verify functionality of the BooleanVar variable class
    """
    def setUp(self):
        self.bvar = BooleanVar('name', 'description')
    
    def testValidation(self):
        """ check to see that various inputs result in a Boolean Value
        """
        for val in ('f','F','n','N','false',0):
            self.failIf(self.bvar.validate(val))
        
        for val in ('t','T','y','Y','true',1):
            self.failUnless(self.bvar.validate(val))
        
        self.assertRaises(ValidationException, self.bvar.validate, 'humpty-dumpty')    
示例#2
0
class test_BooleanVar(unittest.TestCase):
    """ verify functionality of the BooleanVar variable class
    """
    def setUp(self):
        self.bvar = BooleanVar('name', 'description')

    def testValidation(self):
        """ check to see that various inputs result in a Boolean Value
        """
        for val in ('f', 'F', 'n', 'N', 'false', 0):
            self.failIf(self.bvar.validate(val))

        for val in ('t', 'T', 'y', 'Y', 'true', 1):
            self.failUnless(self.bvar.validate(val))

        self.assertRaises(ValidationException, self.bvar.validate,
                          'humpty-dumpty')
示例#3
0
class Plone(BasicZope):
    _template_dir = 'templates/plone'
    summary = "A project for Plone add-ons"
    help = """
This creates a Plone project (to create a Plone *site*, you probably
want to use the one of the templates for a buildout).

To create a Plone project with a name like 'plone.app.myproject' 
(2 dots, a 'nested namespace'), use the 'plone_app' template.
"""
    category = "Plone Development"
    required_templates = ['basic_namespace']
    use_local_commands = True
    use_cheetah = True
    vars = copy.deepcopy(BasicZope.vars)
    vars.insert(5, BooleanVar(
        'add_profile',
        title='Register Profile',
        description='Should this package register a GS Profile',
        modes=(EASY, EXPERT),
        default=False,
        help="""
If your package has need of a Generic Setup profile, set this value to 'True'.  

Having a Generic Setup profile registered makes your package 'installable'
using the ZMI portal_quickinstaller or Plone's 'Add/Remove Products' control
panel.  This allows any portions of your package that require Generic
Setup--such as portlets, content types, actions and so on--to be
properly installed.
"""
    ))
    get_var(vars, 'namespace_package').default = 'plone'
    get_var(vars, 'package').default = 'example'
    
    def post(self, command, output_dir, vars):
        if vars['add_profile'] == False:
            # if we do not want a profile, remove it.            
            path = os.path.join(output_dir,
                                vars['namespace_package'],
                                vars['package'])
            try:
                shutil.rmtree(os.path.join(path, 'profiles'))
            except OSError, e:
                msg = """WARNING: Error in template rendering:

%s

Your package may have structural problems, please check before 
using it.
"""
                self.post_run_msg = msg % str(e)
            
        super(Plone, self).post(command, output_dir, vars)
示例#4
0
 def setUp(self):
     """ set up some basics for the coming tests
     """
     self.vars = [
         var('basic_var', 'This is a basic variable',
             title="Basic Title", default="foo",
             modes=(EXPERT, EASY)),
         BooleanVar('bool_var', 'This is a boolean variable',
                    title="Boolean Title", default=False, page='Main',
                    modes=(EASY)),
         StringVar('str_var', 'This is a string variable',
                   title="String Title", default="string", page='Carl',
                   modes=(EXPERT)),
         TextVar('txt_var', 'This is a text variable', page='Martin',
                 title="Text Title", default="text",
                 modes=()),
         DottedVar('dot_var', 'This is a dotted variable',
                   title="Dotted Title", default="dotted.variable")
     ]
     self.template = BaseTemplate('my_name')
     create = get_commands()['create'].load()
     command = create('create')
     command.parse_args(['-t','archetype'])
     self.command = command
示例#5
0
import copy
from zopeskel.basic_namespace import BasicNamespace
from zopeskel.nested_namespace import NestedNamespace
from zopeskel.vars import BooleanVar

VAR_ZOPE2 = BooleanVar(
        'zope2product',
        title='Zope2 Product?',
        description='Are you creating a product for Zope2/Plone or an Archetypes Product?',
        default=True,
        modes=(),
        help="""
Zope2 products will have a registration hook in their __init__.py,
used by the Zope2 machinery to handle any required processes during
server startup. Archetypes projects will require this, and all
projects for Zope2/Plone will benefit from it (even if not strictly
required, this allows the project to appear in places like the
Zope2 Control Panel list of products).

An appropriate time to choose False here would be if you are creating
a completely Zope3-only or non-Zope project.
"""
        )

class AbstractZope(BasicNamespace):
    """Abstract class for Zope-based packages in a namespace."""
    vars = copy.deepcopy(BasicNamespace.vars)
    vars.append(VAR_ZOPE2)
    category = "Zope Development"

class AbstractNestedZope(NestedNamespace):
示例#6
0
 def setUp(self):
     self.bvar = BooleanVar('name', 'description')
示例#7
0
class BasicNamespace(BaseTemplate):
    _template_dir = 'templates/basic_namespace'
    summary = "A basic Python project with a namespace package"
    ndots = 1
    help = """
This creates a Python project without any Zope or Plone features.
"""
    category = "Core Python"

    required_templates = []
    use_cheetah = True
    vars = copy.deepcopy(BaseTemplate.vars)
    vars += [
        DottedVar(
            'namespace_package', 
            title='Namespace Package Name',
            description='Name of outer namespace package',
            default='plone', 
            modes=(EXPERT,), 
            page='Namespaces',
            help="""
This is the name of the outer package (Python folder) for this project.
For example, in 'Products.PloneFormGen', this would be 'Products'.
This will often be (for Plone products) 'Products'; it may also be
the name of your company/project, or a common-style name like
(for Plone products) 'collective'.

Note that, for some templates, there may be two namespaces, rather
than one (to create eggs with names like 'plone.app.blog')--in this
case, this would be 'plone', the first of the enclosing namespaces.
            """
            ), 

        DottedVar(
            'package', 
            title='Package Name',
            description='Name of the inner namespace package',
            default='example', 
            modes=(EXPERT,), 
            page='Namespaces',
            help="""
This is the name of the innermost package (Python folder) for this project.
For example, in 'Products.PloneFormGen', this would be 'PloneFormGen'.

Note that, for some templates, there may be only a package name without
a namespace package around it--in this case, this would be just the name
of the package.
"""
            ),

        StringVar(
            'version', 
            title='Version',
            description='Version number for project',
            default='1.0', 
            modes=(EASY, EXPERT), 
            page='Metadata',
            help="""
This becomes the version number of the created package. It will be set
in the egg's setup.py, and may be referred to in other places in the
generated project.    
"""
            ),

        StringVar(
            'description',
            title='Description',
            description='One-line description of the project', 
            default='',
            modes=(EASY, EXPERT), 
            page='Metadata',
            help="""
This should be a single-line description of your project. It will be
used in the egg's setup.py, and, for Zope/Plone projects, may be used
in the GenericSetup profile description.
"""
            ),

        TextVar(
            'long_description', 
            title='Long Description',
            description='Multi-line description (in ReST)', 
            default='',
            modes=(), 
            page='Metadata',
            help="""
This should be a full description for your project. It will be
used in the egg's setup.py.

It should be entered in 'restructured text' format; for information,
see http://docutils.sourceforge.net/rst.html).
"""
            ),

        StringVar(
            'author',
            title='Author',
            description='Name of author for project',
            modes=(), 
            page='Metadata',
            help="""
This should be the name of the author of this project. It will be used
in the egg's setup.py, and, for some templates, in the generated
documentation/README files.
"""
            ),

        StringVar(
            'author_email',
            title='Author Email', 
            description='Email of author for project',
            modes=(), 
            page='Metadata',
            help="""
This should be the name of the author of this project. It will be used
in the egg's setup.py, and, for some templates, in the generated
documentation/README files.
"""
            ),

        StringVar('keywords',
            title='Keywords',
            description='List of keywords, space-separated', 
            modes=(), 
            page='Metadata',
            help="""
This should be the list of keywords for this project. This will be
used in the egg's setup.py (and, if this egg is later published on
PyPI, will be used to categorize the project).
"""
            ),
            
        StringVar(
            'url', 
            title='Project URL',
            description='URL of the homepage for this project',
            modes=(), 
            page='Metadata',
            default='http://svn.plone.org/svn/collective/',
            help="""
This should be a URL for the homepage for this project (if applicable).
It will be used in the egg's setup.py.
"""
            ),

        StringVar(
            'license_name', 
            title='Project License',
            description='Name of license for the project',
            default='GPL', 
            modes=(), 
            page='Metadata',
            help="""
The license that this project is issued under. It will be used in the
egg's setup.py.

Common choices here are 'GPL' (for the GNU General Public License),
'ZPL' (for the Zope Public License', and 'BSD' (for the BSD license).
"""
            ),

        BooleanVar(
            'zip_safe',
            title='Zip-Safe?',
            description='Can this project be used as a zipped egg? (true/false)',
            default=False,
            modes=(), 
            page='Metadata',
            help="""
Some eggs can be used directly by Python in zipped format; others must
be unzipped so that their contents can be properly used. Zipped eggs
are smaller and may be easier to redistribute.

Most Zope/Plone projects cannot be used in zipped format; if unsure,
the safest answer is False.
            """
            ),
        ]

    def check_vars(self, vars, command):
        if not command.options.no_interactive and \
           not hasattr(command, '_deleted_once'):
            del vars['package']
            command._deleted_once = True
        return super(BasicNamespace, self).check_vars(vars, command)
示例#8
0
class StandardHosting(abstract_buildout.AbstractBuildout):
    _template_dir = "templates/plone_hosting"
    use_cheetah = True
    summary = "Plone hosting: buildout with ZEO and Plone versions below 3.2"
    required_templates = []
    help = """
This template helps you to create an entire zope hosting setup, including
ZEO and a single Zope client instance.  If you desire, it can also install
and set up the Varnish Caching/Proxy Server.    

Please Note:
Due to changes in the packaging of Plone, this template is not suitable
for versions of Plone beyond 3.1.7.  If you are trying to use a later 
version of plone, you will need to edit the buildout resulting from this
template in order to have it work correctly.  Information related to these
issues may be found here:

http://plone.org/documentation/kb/repair-a-plone-3.1-buildout

and here:

http://plone.org/products/zopeskel/issues/25
"""

    vars = copy.deepcopy(abstract_buildout.AbstractBuildout.vars)
    vars = [
        abstract_buildout.VAR_ZOPE_USER,
        abstract_buildout.VAR_ZOPE_PASSWD,
        IntVar(
            "base_port",
            title="Base Port #",
            description="# to use as base for Zope/ZEO/proxy ports",
            modes=(EASY, EXPERT),
            page="Main",
            default=8000,
            help="""
For standardization, rather than selecting ports for Zope, ZEO, and
a proxy individually, these are tied together numerically.

ZEO port = Base + 0 | Proxy port = Base + 1 | HTTP port = Base + 10

If the ports specified by any of these numbers are already in use or
otherwise unavailable, this template will inform you of the problem and
exit with an error.  If this happens, please try another number for
'Base Port #'
""",
        ),
        BooleanVar(
            "proxy",
            title="Install proxy server?",
            description="Should a proxy server be installed?",
            default=False,
            help=""" 
If you ask for a proxy server to be installed, this template will include
the Varnish Caching/Proxy server.  If you wish to use a different proxy
server, please answer False and install your own.  
""",
        ),
        StringVar(
            "plone",
            title="Plone Version",
            description="Version to install (2.5, 2.5.1, 3.0, 3.0.1, etc)",
            default="3.1.7",
            help="""
You can use this template to install any version of Plone from 2.5 on. 
Versions of Plone more recent than 3.1.7 will require some editing of the
generated configuration files.  Please see the long description of this
template (run 'zopskel --list') for more details.  In general it is 
advisable to use the most recent version of Plone.  You can find a list of 
stable Plone releases at 

http://plone.org/products/plone/releases/

""",
        ),
        BooleanVar(
            "buildout",
            title="Run Buildout?",
            description="Should bin/buildout command be executed?",
            default=True,
            help="""
Would you like this template to automatically run the buildut command as soon
as it finishes creating the required files?  Please note that if you've chosen
to build a version of Plone more recent than 3.1.7 running buildout will fail
unless you make changes to the generated configuration files.  Please see the
long description of this package (run 'zopeskel --list') for more details.

If you intend on adding any specific third-party products or modifying the
buildout in any way, you should answer 'False'.  Then make your modifications
and run `python bootstrap.py` followed by `bin/buildout`.
""",
        ),
    ]

    def _buildout(self, output_dir):
        olddir = os.getcwd()
        try:
            os.chdir(output_dir)
            print "Bootstrapping the buildout"
            subprocess.call([sys.executable, "bootstrap.py"])
            print "Configuring the buildout"
            subprocess.call(["bin/buildout", "-n"])
        finally:
            os.chdir(olddir)

    def _checkPortAvailable(self, port):
        s = socket.socket()
        try:
            s.connect(("127.0.0.1", port))
        except socket.error, e:
            s.close()

            if e.args[0] == errno.ECONNREFUSED:
                return

            raise BadCommand("Error checking port availability: %s" %
                             e.args[1])

        s.close()
        raise BadCommand("Port %s is already in use" % port)
示例#9
0
 def setUp(self):
     self.bvar = BooleanVar('name', 'description')
示例#10
0
import copy

from zopeskel.plone import BasicZope
from zopeskel.base import get_var
from zopeskel.base import EASY, EXPERT
from zopeskel.vars import BooleanVar

dex_vars = [
    BooleanVar('grokish',
        title='Grok-Based?',
        description="True/False: Use grok conventions to simplify coding?",
        modes=(EASY, EXPERT),
        default=True,
        help="""
Grok is a convention-over-configuration framework that simplifies
many aspects of the Zope Component Architecture. Grok makes it easier
to learn and use Dexterity, but it is not part of Plone's core. The
Dexterity Developer Manual examples use grok conventions.
""",
        ),
    BooleanVar('relations',
        title='Use relations?',
        description="True/False: include support for relations?",
        modes=(EASY, EXPERT),
        default=False,
        help="""
Relations support adds support for creating relations between
content objects. This also is easy to add later.
""",
        ),
    ]
示例#11
0
Typically, this will be 'Plone Default', the standard Plone theme.
Unless you are certain what you are doing, keep this choice.
"""),
    BooleanVar(
        'empty_styles',
        title='Empty Styles?',
        description='Override default public stylesheets with empty ones?',
        modes=(EASY, EXPERT),
        page='Main',
        default=False,
        help="""
If this is not selected, your new theme will have the same CSS as the
theme you are descending from (your skin base, answered above).

If this is selected, your theme will have empty CSS files for several
common 'public' areas--thereby starting you off with a theme that has
less of the skin base's look and feel.

Typically, if you are descending from Plone Default, this effectively
hides some of the 'plone look and feel' from your theme; you'd then
have to write CSS to provide more of your own look and feel.

You can always refine the choice made here--to hide more of the base
theme, create additional empty CSS files in your new theme to override
other standard CSS files. To gain back some of the lost base look,
you can just delete these overriding CSS files from your theme
and the originals will now shine through.
"""),
    BooleanVar('include_doc',
               title='Include Documentation?',
               description="Include in-line documentation in generated code?",