[BlueBream] Loading initial data into DB from paster

Christian Klinger cklinger at novareto.de
Tue May 24 09:46:43 EDT 2011


Hi Joe,

i guess you use a buildout environment.

First you have to add a script section in your buildout:

[initializeapp]
recipe = z3c.recipe.dev:script
eggs = myapp
module = myapp.initialize
method = main

Ok then you have to create your initialize script:

import sys
import os
import code
import zdaemon.zdctl
import zope.app.wsgi
import zope.app.debug
from zope.app.publication.zopepublication import ZopePublication

def main(self)
     # Setup der Site
     zope_conf=os.path.join('parts', 'etc', 'zope.conf')
     db = zope.app.wsgi.config(zope_conf)
     connection = db.open()
     root = connection.root()[ZopePublication.root_name]
     import pdb; pdb.set_trace()


After running buildout you should have a script called bin/initializeapp

Which calls the main function in initialize.py.
The pdb stops at with the root folder. You can import your stuff from there.

HTH
Christian



> Hello all,
>
> What is the preferred way to load initial data into the db?
>
> I am trying to add an "initialize" command to "paster" so that I can do
> something like:
>
>    ./bin/paster initialize
>
> I am stuck at opening the DB using the 'zope_conf'. Any
> pointers/tutorial would be great.
>
> Thank you,
>
>




More information about the bluebream mailing list