Example #1
0
class Plone25Theme(Plone):
    _template_dir = 'templates/plone2.5_theme'
    summary = "A theme for Plone 2.5"
    help = """
This creates a project for a theme for Plone 2.5
"""
    category = "Plone Theme Development"
    required_templates = ['plone']
    use_cheetah = True

    vars = copy.deepcopy(Plone.vars)
    get_var(vars, 'namespace_package').default = 'Products'
    get_var(vars, 'description').default = 'An installable theme for Plone 2.5'
    get_var(vars, 'keywords').default = 'web zope plone theme'
    #add_profile should always default to True for theme packages
    get_var(vars, 'add_profile').default = True
    #add_profile need not appear as a question for theme packages
    get_var(vars, 'add_profile').modes = ()
    vars = vars[:3] + theme_vars + vars[3:]

    def pre(self, command, output_dir, vars):
        if vars['skinname'] == '':
            # A title is needed in profiles.zcml otherwise adding a
            # Plone Site will throw an error when displaying the
            # extension profiles.
            vars['skinname'] = 'Custom Theme'
        super(Plone25Theme, self).pre(command, output_dir, vars)

    def post(self, command, output_dir, vars):
        if str(vars['empty_styles']) == 'False':
            np, p = vars['namespace_package'], vars['package']
            cleanupStylsheets(os.path.join(output_dir, np, p, 'skins'))
        super(Plone25Theme, self).post(command, output_dir, vars)
Example #2
0
class Collective(Plone):
    """Plone addon (collective)"""
    _template_dir = "templates/toutpt_collective"
    summary= u"A collective package"

    use_local_commands = False #or setup.cfg will be re created

    vars = copy.deepcopy(Plone.vars)
    get_var(vars, 'description').default = 'Addon for Plone'
    get_var(vars, 'url').default =  'https://github.com/collective/'

    def post(self, command, output_dir, vars):
        super(Collective, self).post(command, output_dir, vars)

        #remove setup.cfg
        path = os.path.join(output_dir)
        try:
            os.remove(os.path.join(path, 'setup.cfg'))
        except OSError, e:
            msg = """WARNING: Could not find setup.cfg: %s"""
            self.post_run_msg = msg % str(e)

        #add gitignore
        try:
            os.rename(os.path.join(path, 'gitignore'),
                      os.path.join(path, '.gitignore'))
        except OSError, e:
            msg = """WARNING: Could not create .gitignore file: %s"""
            self.post_run_msg = msg % str(e)
Example #3
0
class BasicZope(abstract_zope.AbstractZope):
    _template_dir = 'templates/basic_zope'
    summary = "A Zope project"
    help = """
This creates a Zope project without any specific Plone features.
"""
    required_templates = ['basic_namespace']
    use_cheetah = True

    vars = copy.deepcopy(abstract_zope.AbstractZope.vars)
    get_var(vars, 'namespace_package').default = 'myzopelib'
    get_var(vars, 'package').default = 'example'
Example #4
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)
Example #5
0
class Recipe(NestedNamespace):
    """A template for buildout recipes"""
    _template_dir = 'templates/recipe'
    summary = "A recipe project for zc.buildout"
    help = """
This creates a skeleton for a buildout recipe.
"""
    category = "Buildout"
    required_templates = []
    use_cheetah = True
    vars = copy.deepcopy(NestedNamespace.vars)
    get_var(vars, 'namespace_package2').default = 'recipe'
    get_var(vars, 'license_name').default = 'ZPL'
Example #6
0
class Plone3Portlet(PloneApp):
    _template_dir = 'templates/plone3_portlet'
    summary = "A Plone 3 portlet"
    help = """
This creates a Plone project for a portlet.
"""
    required_templates = ['nested_namespace']
    use_cheetah = True

    vars = copy.deepcopy(PloneApp.vars)
    get_var(vars, 'namespace_package').default = 'collective'
    get_var(vars, 'namespace_package2').default = 'portlet'
    vars.append(
        StringVar(
            'portlet_name',
            title='Portlet Name',
            description='Name of portlet (human readable)',
            modes=(EASY,EXPERT),
            default='Example Portlet',
            help="""
This becomes the human-readable title of the portlet.
It gets generated in the GenericSetup profile file for the portlet.
It appears in the Plone UI when managing portlets.
"""
        )
        )
    vars.append(
        DottedVar(
            'portlet_type_name',
            title='Portlet Type Name',
            description='Name of portlet type (actual name)',
            modes=(EASY, EXPERT),
            default='ExamplePortlet',
            help="""
This becomes the actual name of the portlet. It is not displayed
in the Plone UI, but is the name it is registered under, and is
used as the class name for the portlet, and is used in the
generated GenericSetup profile.
"""
        )
        )

    def pre(self, command, output_dir, vars):
        vars['zip_safe'] = False
        vars['portlet_filename'] = vars['portlet_type_name'].lower()
        vars['dotted_name'] = "%s.%s.%s" % (vars['namespace_package'],
                                            vars['namespace_package2'],
                                            vars['package'])

        super(Plone3Portlet, self).pre(command, output_dir, vars)
Example #7
0
class NestedNamespace(BasicNamespace):
    _template_dir = 'templates/nested_namespace'
    summary = "A basic Python project with a nested namespace (2 dots in name)"
    ndots = 2
    help = """
This creates a Python project without any Zope or Plone features.
"""
    required_templates = []
    use_cheetah = True

    vars = copy.deepcopy(BasicNamespace.vars)
    get_var(vars, 'namespace_package').default = 'plone'
    vars.insert(2, VAR_NS2)
    get_var(vars, 'package').default = 'example'
Example #8
0
class Dexterity(BasicZope):
    _template_dir = 'templates/dexterity'
    summary = "A Dexterity-based product"
    help = """
"""
    category = "Plone Development"
    required_templates = ['basic_namespace']
    use_local_commands = True
    use_cheetah = True
    vars = copy.deepcopy(BasicZope.vars)
    vars += dex_vars
    get_var(vars, 'namespace_package').default = 'plone'
    get_var(vars, 'package').default = 'example'
    get_var(vars, 'description').default = 'Example Dexterity Product'
    get_var(vars, 'license_name').default = 'GPL version 2'
Example #9
0
class Plone3Theme(Plone25Theme):
    _template_dir = 'templates/plone3_theme'
    summary = "A theme for Plone 3"
    help = """
This creates a project for a theme for Plone 3.
"""
    required_templates = ['plone']
    use_cheetah = True

    vars = copy.deepcopy(Plone25Theme.vars)
    get_var(vars, 'namespace_package').default = 'plonetheme'
    get_var(vars, 'description').default = 'An installable theme for Plone 3'
    #add_profile should always default to True for theme packages
    get_var(vars, 'add_profile').default = True
    #add_profile need not appear as a question for theme packages
    get_var(vars, 'add_profile').modes = ()
Example #10
0
class DiazoTheme(BasicZope):
    _template_dir = 'templates/diazotheme'
    summary = "Diazo Theme package with css and js resources"
    help = """
"""
    category = "Plone Development"
    required_templates = ['basic_namespace']
    use_local_commands = False
    use_cheetah = True
    vars = copy.deepcopy(BasicZope.vars)
    get_var(vars, 'namespace_package').default = 'diazotheme'
    get_var(vars, 'package').default = 'example'
    get_var(vars, 'description').default = 'Example Diazo Theme Package'
    get_var(vars, 'license_name').default = 'GPL version 2'

    def pre(self, command, output_dir, vars):
        vars['include_doc'] = True
Example #11
0
class KssPlugin(abstract_zope.AbstractNestedZope):
    _template_dir = 'templates/kss_plugin'
    summary = "A project for a KSS plugin"
    ndots = 2
    help = """
This creates a project for a KSS plugins ('Kinetic Style Sheets', a 
Plone 3 framwork for JavaScript/AJAX).
"""
    category = "Plone Development"

    required_templates = []
    use_cheetah = True

    vars = copy.deepcopy(abstract_zope.AbstractNestedZope.vars)
    get_var(vars, 'namespace_package').default = 'kss'
    get_var(vars, 'namespace_package2').default = 'plugin'
    get_var(vars, 'keywords').default = 'kss plugin'
Example #12
0
class Archetype(Plone):
    _template_dir = 'templates/archetype'
    summary = 'A Plone project that uses Archetypes content types'
    help = """
This creates a Plone project that uses Archetypes content types.
It has local commands that will allow you to add content types
and to add fields to your new content types.
"""
    post_run_msg = """
There is a local command to add individual Archetype content types
and to add fields to those content types. See the instructions above
on how to use this command.
"""

    required_templates = ['plone']
    use_cheetah = True
    use_local_commands = True

    vars = copy.deepcopy(Plone.vars)
    vars.insert(
        1,
        StringVar('title',
                  title='Project Title',
                  description='Title of the project',
                  modes=(EASY, EXPERT),
                  default='Example Name',
                  help="""
This becomes the title of the project. It is used in the 
GenericSetup registration for the project and, as such, appears
in Plone's Add/Remove products form.
"""))
    #zope2product should always defaults to True
    get_var(vars, 'zope2product').default = True
    #add_profile should always default to True for archetype packages
    get_var(vars, 'add_profile').default = True
    #add_profile need not appear as a question for archetype packages
    get_var(vars, 'add_profile').modes = (EXPERT, )

    def post(self, command, output_dir, vars):
        # Remove tests.py -- we already have a tests/ package
        path = os.path.join(output_dir, vars['namespace_package'],
                            vars['package'])
        os.remove(os.path.join(path, 'tests.py'))

        super(Archetype, self).post(command, output_dir, vars)
Example #13
0
class EEA(BasicZope):
    """ EEA ZopeSkel templates
    """
    _template_dir = 'templates/eea'
    summary = "EEA-based package"
    help = ""
    category = "EEA"
    required_templates = []
    use_local_commands = True
    use_cheetah = True
    variables = copy.deepcopy(BasicZope.vars)
    variables.insert(
        1,
        StringVar('title',
                  title='Project Title',
                  description='Title of the project',
                  modes=(EASY, EXPERT),
                  default='EEA Dummy Package',
                  help="""
        This becomes the title of the project. It is used in the
        GenericSetup registration for the project and, as such, appears
        in Plone's Add/Remove products form.
        """))
    variables.insert(
        2,
        StringVar('ctype',
                  title='Archetypes Content-Type',
                  description='Archetypes Content-Type Class',
                  modes=(EASY, EXPERT),
                  default='DummyDocument',
                  help="This creates an archetypes content-type."))
    variables.insert(
        3,
        StringVar(
            'folderish',
            title='Is folderish',
            description='Is this content-type folderish?',
            modes=(EASY, EXPERT),
            default='True',
            help="This creates an archetypes content-type folderish or not"))

    get_var(variables, 'namespace_package').default = 'eea'
    get_var(variables, 'package').default = 'example'
    get_var(variables, 'description').default = 'EEA Package'
    get_var(variables, 'license_name').default = 'GPL version 2'
    get_var(variables, 'author').default = 'European Environment Agency'
    get_var(variables, 'author_email').default = '*****@*****.**'
    get_var(variables, 'keywords').default = 'eea zope plone python'
    get_var(variables, 'url').default = 'https://eea.github.io'

    def pre(self, command, output_dir, variables):
        """ Pre
        """
        variables['ctype'] = variables['ctype'].title().replace(" ", "")
        variables['ctype_module'] = variables['ctype'].lower()
Example #14
0
 def test_get_vars(self):
     """ get_vars is not a method of BaseTemplate, but we've got a nice set
         of variables all set up in here, so let's use it
     """
     var = get_var(self.vars, 'basic_var')
     self.assertEqual(var.name, 'basic_var')
     self.assertEqual(var.title, 'Basic Title')
     self.assertEqual(var.description, 'This is a basic variable')
     self.assertEqual(var.modes, (EXPERT, EASY))
     self.assertEqual(var.default, 'foo')
Example #15
0
class CollectiveJS(NestedNamespace):
    category = "Plone Development"
    _template_dir = "templates/toutpt_collectivejs"
    summary = u"A package to embed a javascript"
    ndots = 2
    use_local_commands = False  #or setup.cfg will be re created
    use_cheetah = True

    vars = copy.deepcopy(NestedNamespace.vars)
    get_var(vars, 'namespace_package').default = 'collective'
    get_var(vars, 'namespace_package2').default = 'js'

    def post(self, command, output_dir, vars):
        #add gitignore
        path = os.path.join(output_dir)
        try:
            os.rename(os.path.join(path, 'gitignore'),
                      os.path.join(path, '.gitignore'))
        except OSError, e:
            msg = """WARNING: Could not create .gitignore file: %s"""
            self.post_run_msg = msg % str(e)
Example #16
0
class Plone2Theme(BaseTemplate):

    # This does not descend from AbstractZope, since it's not
    # a egg package, but just a raw Zope Product (unlike other
    # templates)

    _template_dir = 'templates/plone2_theme'
    summary = "A theme for Plone 2.1"
    ndots = 0
    help = """
This creates a project for a theme for Plone 2.1.

This is not an egg, but a classic Product, and therefore is usable in
Plone 2.1. This product should also work, without changes, in Plone
2.5, though you may prefer to use the 'plone25_theme' template for
this, as this will build an eggified Plone 2 theme.

This template expects a name that is just the name of a classic
product--a legal Python identifer without any dots in the name.
"""
    category = "Plone Development"

    use_cheetah = True

    vars = copy.deepcopy(BasicPackage.vars)
    get_var(vars, 'description').default = 'An installable theme for Plone'
    get_var(vars, 'keywords').default = 'web zope plone theme'
    vars = theme_vars + vars[:3] + vars[4:6]

    def pre(self, command, output_dir, vars):
        if vars['skinname'] == '':
            # It is always good to have a name for the skin.
            vars['skinname'] = 'Custom Skin'
        super(Plone2Theme, self).pre(command, output_dir, vars)

    def post(self, command, output_dir, vars):
        if str(vars['empty_styles']) == 'False':
            cleanupStylsheets(os.path.join(output_dir, 'skins'))
        super(Plone2Theme, self).post(command, output_dir, vars)
Example #17
0
class Plone3Theme(ZSPlone3Theme):
    _template_dir = 'templates/plone3_theme'
    summary = 'A Theme for Plone 3/4 with no browser resources'
    skinbase = 'Sunburst Theme'
    use_local_commands = True

    vars = copy.deepcopy(ZSPlone3Theme.vars)

    get_var(vars, 'version').default = '1.0'
    get_var(vars, 'version').modes = ()

    get_var(vars,
            'description').default = 'Installable theme: %s.%s' % (get_var(
                vars, 'namespace_package'), get_var(vars, 'package'))
    get_var(vars, 'description').modes = ()

    get_var(vars, 'empty_styles').default = True
    get_var(vars, 'empty_styles').modes = ()

    get_var(vars, 'include_doc').default = True
    get_var(vars, 'include_doc').modes = ()

    def post(self, command, output_dir, vars):
        pass
Example #18
0
class Plone25Buildout(Plone3Buildout):
    _template_dir = 'templates/plone2.5_buildout'
    summary = "A buildout for Plone 2.5 projects"
    help = """
This template creates a buildout for Plone 2.5, appropriate for
development. If you also need ZEO or caching, you may wish to look
at the plone_hosting template.
"""
    required_templates = ['plone3_buildout']

    vars = copy.deepcopy(Plone3Buildout.vars)
    get_var(vars, 'plone_version').default = "2.5.5"

    # The Plone3Buildout has an appropriate "use-the-installer"
    # message, but this wouldn't be right here, so let's
    # override it.
    pre_run_msg = "" 
Example #19
0
class PlonePas(abstract_zope.AbstractNestedZope):
    _template_dir = 'templates/plone_pas'
    summary = "A project for a Plone PAS plugin"
    help = """
This create a project for developing a PAS ('pluggable authentication
system') plugin.
"""
    category = "Plone Development"
    required_templates = ['nested_namespace']
    use_cheetah = True
    use_local_commands = True

    vars = copy.deepcopy(abstract_zope.AbstractNestedZope.vars)
    get_var(vars, 'namespace_package2').default = 'pas'

    def pre(self, command, output_dir, vars):
        vars['multiplugin_name'] = vars['package'].title()
        super(PlonePas, self).pre(command, output_dir, vars)
Example #20
0
class Theme(plone3_theme.Plone3Theme):
    """diazo theme"""
    _template_dir = "templates/toutpt_diazo960"
    summary = u"A diazo theme based on 960 css"

    use_local_commands = False  #or setup.cfg will be re created

    vars = copy.deepcopy(plone3_theme.Plone3Theme.vars)
    get_var(vars,
            'description').default = 'An installable diazo theme for Plone 4'
    get_var(vars, 'skinbase').default = 'Sunburst Theme'
    get_var(vars, 'url').default = 'https://github.com/collective/'
    get_var(vars, 'skinname').default = 'My theme'

    vars.remove(get_var(vars, 'empty_styles'))
    vars.remove(get_var(vars, 'include_doc'))

    def post(self, command, output_dir, vars):
        vars['empty_styles'] = False
        vars['include_doc'] = False
        super(Theme, self).post(command, output_dir, vars)

        #remove setup.cfg
        path = os.path.join(output_dir)
        try:
            os.remove(os.path.join(path, 'setup.cfg'))
        except OSError, e:
            msg = """WARNING: Could not find setup.cfg: %s"""
            self.post_run_msg = msg % str(e)

        #add gitignore
        try:
            os.rename(os.path.join(path, 'gitignore'),
                      os.path.join(path, '.gitignore'))
        except OSError, e:
            msg = """WARNING: Could not create .gitignore file: %s"""
            self.post_run_msg = msg % str(e)
Example #21
0
class CSDjangoProject(BaseTemplate):
    _template_dir = 'templates/cs_django_project'
    summary = 'A basic Django Project'
    use_cheetah = True

    vars = copy.deepcopy(BaseTemplate.vars)
    vars += [
        StringVar('package',
                  'Enter the package name (no spaces, no dashes, no dots'),
        StringVar('version', 'Version (like 0.1)'),
        StringVar('description', 'One-line description of the package'),
        StringVar('keywords', 'Space-separated keywords/tags'),
        StringVar('author', 'Author name'),
        StringVar('author_email', 'Author email'),
        StringVar('url', 'URL of homepage'),
        StringVar('license_name', 'License name'),
        StringVar(
            'zip_safe',
            'True/False: if the package can be distributed as a .zip file',
            default=False),
    ]

    get_var(vars, 'version').default = '1.0'
    get_var(vars, 'version').modes = ()

    get_var(vars, 'description').default = 'Django project. '
    get_var(vars, 'description').modes = ()

    get_var(vars, 'keywords').default = 'django'
    get_var(vars, 'keywords').modes = ()

    get_var(vars, 'author').default = ''
    get_var(vars, 'author').modes = ()

    get_var(vars, 'author_email').default = ''
    get_var(vars, 'author_email').modes = ()

    get_var(vars, 'url').default = 'http://code.codesyntax.com/private/'
    get_var(vars, 'url').modes = ()

    get_var(vars, 'license_name').default = 'GPL'
    get_var(vars, 'license_name').modes = ()

    get_var(vars, 'zip_safe').default = 'False'
    get_var(vars, 'zip_safe').modes = ()