Back to index

plone3  3.1.7
setupSite.py
Go to the documentation of this file.
00001 import os
00002 import sys
00003 
00004 def process(name, swhome, ihome):
00005     admin_username = name
00006     os.environ['INSTANCE_HOME'] = ihome
00007 
00008     if sys.platform == 'win32':
00009         sys.path.insert(0, os.path.join(swhome, 'Zope', 'lib', 'python'))
00010         sys.path.insert(1, os.path.join(swhome, 'Python', 'lib'))
00011         sys.path.insert(2, swhome)
00012     else:
00013         os.environ['SOFTWARE_HOME'] = swhome
00014         sys.path.insert(0, swhome)
00015 
00016     # have to set up env first
00017     try:
00018         # Zope 2.8 on, Zope is now 'Zope2' and 'zope' is the Zope 3
00019         # libs.
00020         import Zope2 as Zope
00021     except ImportError:
00022         import Zope
00023 
00024     configfile = os.path.join(ihome, 'etc', 'zope.conf')
00025 
00026     # nuke remaining command line arguments
00027     sys.argv = sys.argv[:1]
00028 
00029     # for 2.7 run configure
00030     Zope.configure(configfile)
00031     app = Zope.app()
00032 
00033     from Testing import makerequest
00034     app = makerequest.makerequest(app)
00035 
00036     from Products.CMFPlone.PloneInitialize import create
00037     out = create(app, admin_username)
00038     return out
00039 
00040 if __name__=='__main__':
00041     # sys.argv[0] is script name
00042     if len(sys.argv) < 4:
00043         print """
00044 setupSite.py username swhome ihome
00045 
00046 username: the username to setup the site with
00047 swhome: the software home
00048 ihome: the instance home
00049 
00050 note: win32 does this slightly differently
00051 """
00052         sys.exit()
00053 
00054     # for example the following is how i run it on win32
00055     # "c:\Program Files\Plone\python\python" setupSite.py admin "c:\Program Files\Plone\Data" "c:\Program Files\Plone"
00056     # like it says above, win32 is different
00057     # example for Mac OS X (and probably all nix-based OS, adjust paths as required, note "Default" is INSTANCE_HOME and contains Extensions/import/var/Products etc):
00058     # /Applications/Plone2/Software/Zope262/Python/bin/python setupSite.py admin /Applications/Plone2/Software/Zope262/Zope/lib/python /Applications/Plone2/Sites/Default
00059     name, swhome, ihome = sys.argv[1:]
00060     process(name, swhome, ihome)