In the past, deploying a Zope/Plone application was a cumbersome task wrought with peril. Buildout has ushered in a new era of repeatability and ease of use. Spending hours to get your co-workers set up with just the right set of products and python libraries has come to an end. Six Feet Up's Lead Developer Clayton Parker will show you how to use buildout from your local development instance to the full blown production server instance with one buildout.
24. Extending Configuration
• buildout.cfg
• profiles/
• base.cfg
• development.cfg
• debug.cfg
• qa.cfg
• prod.cfg
• versions.cfg
si xf eet up .co m /dw 0 8
25. buildout.cfg
[buildout]
# the profile we want to use
extends = profiles/development.cfg
find-links =
http://dist.plone.org
http://download.zope.org/distribution/
http://effbot.org/downloads
si xf eet up .co m /dw 0 8
34. Baby Steps
$ cd path/to/mybuildout
$ python2.4 bootstrap.py
Creating directory 'mybuildout/bin'.
Creating directory 'mybuildout/parts'.
Creating directory 'mybuildout/develop-eggs'.
Generated script 'mybuildout/bin/buildout'.
$ bin/buildout
$ bin/instance start
si xf eet up .co m /dw 0 8
35. Options
• -v and -q
• increase and decrease verbosity
• -n and -N
• Newest and non-newest modes
• -O and -o
• online and offline mode
• -t
• socket timeout
si xf eet up .co m /dw 0 8
36. Update your buildout
$ bin/buildout -v
$ bin/buildout -Nvvv
$ bin/buildout -No
$ bin/buildout -t 60
si xf eet up .co m /dw 0 8
37. Assignments
$ bin/buildout instance:debug-mode=on
$ bin/buildout buildout:log-level=70
$ bin/buildout -N instance:debug-mode=on -v
si xf eet up .co m /dw 0 8
38. Commands
$ bin/buildout install
$ bin/buildout -Nv install zope2 instance
$ bin/buildout -nv install instance
si xf eet up .co m /dw 0 8
39. Create Recipes
$ paster create -t recipe my.recipe.example
si xf eet up .co m /dw 0 8
40. Recipe
• Recipe class
• constructor
• install
• update
• uninstall (optional)
si xf eet up .co m /dw 0 8
41. class Recipe:
quot;quot;quot;quot;A recipe
quot;quot;quot;quot;
def __init__(self, buildout, name, options):
self.buildout = buildout
self.name = name
self.options = options
# gather options from other parts here
options['notmine'] = buildout['someotherpart']['foobar']
def install(self):
quot;quot;quot;quot;Install method
quot;quot;quot;
options = self.options
location = options['location']
# must return a string, or an iterable of strings
return location
def update(self):
quot;quot;quot;Update method
quot;quot;quot;
pass
si xf eet up .co m /dw 0 8
42. class Recipe:
Real World
quot;quot;quot;infrae.subversion recipe.
quot;quot;quot;
def __init__(self, buildout, name, options):
self.buildout = buildout
self.name = name
self.options = options
options['location'] = self.location = os.path.join(
buildout['buildout']['parts-directory'], self.name)
self.urls = [l.split()
for l in options['urls'].splitlines()
if l.strip()]
self.export = options.get('export')
self.newest = (
buildout['buildout'].get('offline', 'false') == 'false'
and
buildout['buildout'].get('newest', 'true') == 'true'
)
self.verbose = buildout['buildout'].get('verbosity', 0)
si xf eet up .co m /dw 0 8
43. Install Method
def install(self):
quot;quot;quot;Checkout the checkouts.
quot;quot;quot;
for (url, name) in self.urls:
wc = py.path.svnwc(self.location).join(name)
if self.export:
raise Exception('Unimplemented feature')
if self.verbose:
print quot;Fetch %squot; % url
wc.checkout(url)
return self.location
si xf eet up .co m /dw 0 8
44. def update(self):
quot;quot;quot;Update the checkoutsquot;quot;quot;
if not self.newest:
return self.location
if self.export:
return self.location
if self.options.get('ignore_updates', False):
return self.location
num_release = re.compile('.*@[0-9]+$')
part = py.path.local(self.location)
for link, sub_path in self.urls:
if num_release.match(link):
if self.verbose:
print quot;Given num release for %s, skipping.quot; % link
continue
wc = py.path.svnwc(self.location).join(sub_path)
if self.verbose:
print quot;Updating %squot; % link
wc.update()
return self.location
si xf eet up .co m /dw 0 8
45. Wrapping Up
• Buildout
• Parts
• Recipes
• Command Line
• ZopeSkel
• Create Buildouts
• Custom Recipes
si xf eet up .co m /dw 0 8