From f7da2e5b81e7e3a4728a76822fc737204b3473e0 Mon Sep 17 00:00:00 2001 From: Carlos de la Guardia Date: Fri, 8 Jun 2012 00:08:22 -0500 Subject: [PATCH] make minimal zope buildout work with filesystem service --- plone/README.txt | 164 +------------------------------ plone/buildout.cfg | 37 ++----- plone/debug_scripts/README.txt | 5 - plone/debug_scripts/checkrefs.py | 56 ----------- plone/requirements.txt | 1 - plone/stackato.yml | 26 ++--- plone/start_plone.py | 32 +++--- 7 files changed, 39 insertions(+), 282 deletions(-) delete mode 100644 plone/debug_scripts/README.txt delete mode 100644 plone/debug_scripts/checkrefs.py delete mode 100644 plone/requirements.txt diff --git a/plone/README.txt b/plone/README.txt index 672a231..720249e 100644 --- a/plone/README.txt +++ b/plone/README.txt @@ -1,161 +1,7 @@ -============================= -Get Started Quickly With Karl -============================= +=========================== +Run Plone CMS on Appsembler +=========================== -PostgreSQL ----------- - -Karl requires PostgreSQL be installed on your system. If you are on OSX, this -is reported to work:: - - $ sudo port install postgresql90 - $ sudo port install postgresql90-server - -Link pg_config to a place that is in the path: - - $ sudo ln -s /opt/local/lib/postgresql90/bin/pg_config /usr/local/bin/ - -Alternately, add /opt/local/lib/postgresql90/bin/ to your path. - -Buildout --------- -Check out the buildout from github:: - - $ git clone git://github.com/karlproject/dev-buildout.git karl - $ cd karl - -Create a virtual environment and run the buildout:: - - $ virtualenv -p python2.6 --no-site-packages . - $ bin/python bootstrap.py - $ bin/buildout - -Karl is now built and ready to run. Run Karl using Paste HTTP server in the -foreground:: - - $ bin/karlserve serve - -Alternatively, you can use Paster:: - - $ bin/paster serve etc/karlserve.ini - -Visit the filesystem ZODB based test instance of Karl at:: - - http://localhost:6543/fs - -Default login and password are admin/admin. - -Relstorage ----------- - -Create the user and database for the PostgreSQL/Relstroage based instance of -Karl:: - - $ createuser -P karltest - (Enter 'test' for password. Repeat. Answer 'n' to next three questions.) - $ createdb -O karltest karltest - -Visit the Relstorage instance at:: - - http://localhost:6543/pg - -Later, if you want to blow away the database and start over:: - - $ dropdb karltest; createdb -O karltest karltest - -Customization Packages ----------------------- - -Both instances are 'vanilla' instances of Karl which do not use any -customization package. Most customers that are not OSI, going forward, will -not use any customization package. To make the pg instance use the 'osi' -customization package:: - - $ bin/karlserve settings set pg package osi - $ bin/karlserve serve (restart if already running) - -To revert back to vanilla:: - - $ bin/karlserve settings remove pg package - -Localization of date formats ----------------------------- - -Karl uses the Globalize javascript library to handle date formatting. It is -recommended that whenever you need to use a date in a Karl or customization -package template, you use Karl's globalize mechanism instead of formatting -the date in Python code. - -To use gloablize, it's best to serve the date to the template in one of two -formats: 'dd/mm/yyyy' for dates and 'dd/mm/yyyy hh:mm:ss' for dates with -times. In the template, the date has to be by itself inside a tag and must -use one of the globalize classes: - - - globalize-short-date: - MM/dd/yyyy (02/15/2012) - - globalize-long-date: - MMMM dd yyyy (February 15 2012) - - globalize-full-date: - dddd, MMMM dd yyyy HH:mm (Wednesday, February 15 2012 12:00) - - globalize-date-time: - M/d/yyyy HH:mm (2/15/2012 12:00) - - globalize-calendar-full: - dddd M/d (Wednesday 2/15) - - globalize-calendar-abbr: - ddd M/d (Wed 2/15) - - globalize-calendar-long: - dddd, MMMM d (Wednesday, February 15) - - globalize-calendar-list: - ddd, MMM d (Wed, Feb 15) - -Globalize will convert the date to the proper format for the current -culture on page load. Default culture is en-US. - -As an example:: - -

02/15/2012

- -Will display an h3 title with the date 'February 15 2012'. The same date will -show up as '15 February 2012' if the user has 'europe' as date format default. - -Users can pick their date formatting culture when editing their own profile. -Currently, the only options are US and Europe (uses en-GB). To set a -different default for the whole site use karlserve settings:: - - $ bin/karlserve settings set pg date_format en-GB - -Hacking -------- - -To hack on some source code:: - - $ bin/develop co karl - $ bin/buildout -No - -Source code will now be in src/karl and src/karlserve. - -When playing with the code it's usually very useful to have some sample -content added to the site, so that it looks a bit closer to a real site. -The karlserve command can be used for that:: - - $ bin/karlserve samplegen - -Using this command 10 sample communities will be added to the site, each -with their own wikis, blogs, calendars and files. - -The samplegen command does not create intranets, so they need to be added -manually if they are required. To do that visit your instance at: - - http://localhost:6543/pg/add_community.html - -Fill the form to add a community, making sure the 'intranets' checkbox is -selected. An 'intranets' tab will be visible on the community pages after -that, from which new intranets can be added. - -If you need to work with versioning, you need to initialize the repository -before the versioning UI will show up. This is done with:: - - $ bin/karlserve init_repozitory pg - -Enjoy! +This is a simple buildout which uses Stackato's filesystem service for +persistence. diff --git a/plone/buildout.cfg b/plone/buildout.cfg index d19da21..9901bde 100644 --- a/plone/buildout.cfg +++ b/plone/buildout.cfg @@ -1,28 +1,22 @@ [buildout] +#relative-paths = true + parts = - client1 - zopepy + instance # Change the number here to change the version of Plone being used extends = - http://download.zope.org/Zope2/index/2.12.18/versions.cfg - http://dist.plone.org/release/4.0.7/versions.cfg -# there's no KGS for plone.app.caching 1.0? - http://good-py.appspot.com/release/plone.app.caching/1.0b2 - http://good-py.appspot.com/release/plone.app.theming/1.0b4 + http://dist.plone.org/release/4.1.4/versions.cfg versions = versions # Add additional egg download sources here. dist.plone.org contains archives # of Plone packages. find-links = - http://dist.plone.org/release/4.0.7 + http://dist.plone.org/release/4.1.4 http://dist.plone.org/thirdparty -# Needed for optional eea.cache -# http://eggrepo.eea.europa.eu/simple # Add additional eggs here eggs = - relstorage python-Levenshtein feedparser @@ -30,37 +24,22 @@ eggs = # e.g.: develop = src/my.package develop = -[client1] +[instance] # For more information on this step and configuration options see: # http://pypi.python.org/pypi/plone.recipe.zope2instance recipe = plone.recipe.zope2instance user = admin:admin -http-address = 8081 -blob-storage = var/blobstorage -shared-blob = on +zeo-client = false +http-address = PLONE_HTTP_PORT debug-mode = off -rel-storage = - type postgres - db %db% - user %dbuser% - passwd %dbpassword% # If you want Zope to know about any additional eggs, list them here. # This should include any development eggs you listed in develop-eggs above, # e.g. eggs = Plone my.package eggs = - Plone ${buildout:eggs} # If you want to register ZCML slugs for any packages, list them here. # e.g. zcml = my.package my.other.package zcml = -[zopepy] -# For more information on this step and configuration options see: -# http://pypi.python.org/pypi/zc.recipe.egg -recipe = zc.recipe.egg -eggs = ${client1:eggs} -interpreter = zopepy -scripts = zopepy - diff --git a/plone/debug_scripts/README.txt b/plone/debug_scripts/README.txt deleted file mode 100644 index d599110..0000000 --- a/plone/debug_scripts/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -The scripts in this folder are meant to be run as an argument to karlserve -debug, eg: - -$ bin/karlserve debug pg -S helpers/checkrefs.py - diff --git a/plone/debug_scripts/checkrefs.py b/plone/debug_scripts/checkrefs.py deleted file mode 100644 index 1fea10b..0000000 --- a/plone/debug_scripts/checkrefs.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -Checks a ZODB database for referential integrity. Will print the zoids for any -references found to non-existant objects. -""" - -from collections import deque - -from ZODB.POSException import POSKeyError -from ZODB.serialize import referencesf -from ZODB.utils import p64, u64 - -def main(): - storage = root._p_jar._storage - connection = getattr(storage, '_load_conn', None) - if connection is not None: - check_relstorage(connection) - else: - check_any_storage(storage) - - -def check_relstorage(connection): - curr_objs = connection.cursor() - cursor = connection.cursor() - curr_objs.execute('select zoid, tid from current_object') - for zoid, tid in curr_objs: - cursor.execute('select state from object_state where zoid=%s and tid=%s', - (zoid, tid)) - state = cursor.fetchone()[0] - if state is None: - continue # How would an object have a null state? - for ref_zoid in referencesf(state): - ref_zoid = u64(ref_zoid) - cursor.execute('select tid from current_object where zoid=%s', - (ref_zoid,)) - if cursor.rowcount == 0: - print "Bad reference found", ref_zoid - - -def check_any_storage(storage): - checked = set() - to_check = deque([p64(0)]) - - while to_check: - check_oid = to_check.popleft() - checked.add(check_oid) - try: - state, tid = storage.load(check_oid) - except POSKeyError: - print "Bad reference found", u64(check_oid) - - for reference in referencesf(state): - if reference not in checked: - to_check.append(reference) - - -main() \ No newline at end of file diff --git a/plone/requirements.txt b/plone/requirements.txt deleted file mode 100644 index 66072c7..0000000 --- a/plone/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -virtualenv diff --git a/plone/stackato.yml b/plone/stackato.yml index 3949d60..95733b4 100644 --- a/plone/stackato.yml +++ b/plone/stackato.yml @@ -1,30 +1,32 @@ -name: plone +name: plonecms mem: 64M instances: 1 framework: - type: python - runtime: python27 + type: python hooks: + pre-staging: + - mkdir $STACKATO_FILESYSTEM/filestorage + - mkdir $STACKATO_FILESYSTEM/blobstorage post-staging: - virtualenv . - - ./bin/python bootstrap.py - - ./bin/buildout + - bin/python bootstrap.py + - bin/buildout + pre-running: + - rm -rf var/filestorage + - rm -rf var/blobstorage + - ln -s $STACKATO_FILESYSTEM/filestorage var/filestorage + - ln -s $STACKATO_FILESYSTEM/blobstorage var/blobstorage services: - postgresql: plonedb + filesystem: zodb processes: - web: ./bin/py ./start_plone.py + web: python2.7 start_plone.py ignores: - .git - .pyc - - bin - - eggs - - var - - develop-eggs - - parts diff --git a/plone/start_plone.py b/plone/start_plone.py index 3ec8fb4..0e43e7d 100644 --- a/plone/start_plone.py +++ b/plone/start_plone.py @@ -1,25 +1,17 @@ import os -import json +def setup_instance(): + port = os.getenv('VCAP_APP_PORT', '8080') + host = os.getenv('VCAP_APP_HOST', '0.0.0.0') -from paste import httpserver -from paste.deploy import loadapp - -CONFIG = """ -dsn = dbname='%(name)s' user='%(user)s' host='%(host)s' password='%(password)s' -""" - -def setup_dbconfig(): - vcap_services = json.loads(os.environ['VCAP_SERVICES']) - cred = vcap_services.values()[0][0]['credentials'] - - dbconfig = CONFIG % cred - - # To do: find the best place to put this - dbconfig_file = open('./parts/relstorage?','w') - dbconfig_file.write(dbconfig) - dbconfig_file.close() + instances_file = open('parts/instance/etc/zope.conf') + instances_file_content = instances_file.read().replace('PLONE_HTTP_PORT', port) + instances_file.close() + + new_instances_file = open('parts/instance/etc/zope.conf', 'w') + new_instances_file.write(instances_file_content) + new_instances_file.close() if __name__ == '__main__': - setup_dbconfig() - os.execv('./bin/client1', ('fg',)) + setup_instance() + os.execl('bin/instance', 'instance', 'fg')