lovely.recipe

HomePage: http://launchpad.net/lovely.recipe

Author: Lovely Systems

Download: https://pypi.python.org/packages/source/l/lovely.recipe/lovely.recipe-1.0.0.tar.gz

        Lovely Recipes
**************

==========================
Filesystem Buildout Recipe
==========================

Creating Directories
====================

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = data-dir
    ... find-links = http://download.zope.org/distribution
    ...
    ... [data-dir]
    ... recipe = lovely.recipe:mkdir
    ... path = ${buildout:directory}/mystuff
    ... """)
    >>> print system(buildout),
    Installing data-dir.
    data-dir: Creating directory /sample-buildout/mystuff

    >>> ls(sample_buildout)
    -  .installed.cfg
    d  bin
    -  buildout.cfg
    d  develop-eggs
    d  eggs
    d  mystuff
    d  parts

If we change the directory name the old directory ('mystuff') is not deleted.

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = data-dir
    ... find-links = http://download.zope.org/distribution
    ...
    ... [data-dir]
    ... recipe = lovely.recipe:mkdir
    ... path = ${buildout:directory}/otherdir
    ... """)
    >>> print system(buildout),
    Uninstalling data-dir.
    Installing data-dir.
    data-dir: Creating directory /sample-buildout/otherdir

    >>> ls(sample_buildout)
    -  .installed.cfg
    d  bin
    -  buildout.cfg
    d  develop-eggs
    d  eggs
    d  mystuff
    d  otherdir
    d  parts

We can also create a full path.

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = data-dir
    ... find-links = http://download.zope.org/distribution
    ...
    ... [data-dir]
    ... recipe = lovely.recipe:mkdir
    ... path = ${buildout:directory}/with/subdir
    ... """)
    >>> print system(buildout),
    Uninstalling data-dir.
    Installing data-dir.
    data-dir: Cannot create /sample-buildout/with/subdir. /sample-buildout/with is not a directory.
    While:
      Installing data-dir.
    Error: Invalid Path

But we need to activate this function explicitely.

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = data-dir
    ... find-links = http://download.zope.org/distribution
    ...
    ... [data-dir]
    ... recipe = lovely.recipe:mkdir
    ... createpath = True
    ... path = ${buildout:directory}/with/subdir
    ... """)
    >>> print system(buildout),
    Installing data-dir.
    data-dir: Creating parent directory /sample-buildout/with
    data-dir: Creating directory /sample-buildout/with/subdir

    >>> ls(sample_buildout)
    -  .installed.cfg
    d  bin
    -  buildout.cfg
    d  develop-eggs
    d  eggs
    d  mystuff
    d  otherdir
    d  parts
    d  with
    >>> ls(sample_buildout + '/with')
    d  subdir

There is no update method so the install method is used upon update
and the directories get recreated.

    >>> rmdir(sample_buildout + '/with')
    >>> print system(buildout),
    Updating data-dir.
    The recipe for data-dir doesn't define an update method. Using its install method.
    data-dir: Creating parent directory /sample-buildout/with
    data-dir: Creating directory /sample-buildout/with/subdir

We can change the owner of the created directory if run as root. This is tested
in mkdir-root.txt.

If not run as root, setting the owner is an error:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = data-dir
    ... find-links = http://download.zope.org/distribution
    ...
    ... [data-dir]
    ... recipe = lovely.recipe:mkdir
    ... createpath = True
    ... path = ${buildout:directory}/another/with/subdir
    ... owner = nobody
    ... """)
    >>> print system(buildout),
    While:
      Installing.
      Getting section data-dir.
      Initializing part data-dir.
    Error: Only root can change the owner to nobody.


It is an error when the user does not exist:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... parts = data-dir
    ... find-links = http://download.zope.org/distribution
    ...
    ... [data-dir]
    ... recipe = lovely.recipe:mkdir
    ... createpath = True
    .