Site News
Plone 4 Upgrade
Last night I decided to take some time to move this site over to Plone 4. The repoze.zope2 build I had previously was buggy and I am starting to dislike Deliverance a bit.
Snags
- the search didn't work because of this migration issue http://dev.plone.org/plone/ticket/10360
- old file types aren't migrated to blob http://dev.plone.org/plone/ticket/10365
- archetypes don't want to use the new add views--should probably report this
- If you have the jquery UI package installed, it'll mess with some of Plone's JS for some reason--I just disabled it.
- some other control panel entries and menu items were not fully migrated, still pointing to old templates
Benefits
- FAST--running this on a linode with 512MB of ram. 2 zeo clients and with CacheSetup, this thing is very fast. Much faster than Plone 3.
- Just more polished than Plone 3--with usability enhancements and a new theme, it's great.
- I haven't found a product that wasn't compatible with Plone 4 yet--although, sometimes I needed to do some digging or use an svn checkout to get the compatible version
Using the zope debug console
First off, go into your instance directory and issue a command like this,
./bin/instance debug
Things to Note
- "app" is the zope root
- You can access your Plone instances and other objects just by issuing the normal ways for traversing objects. For instance,
app.Plone app['Plone']
Login as user
from AccessControl.SecurityManagement import newSecurityManager user = app.acl_users.getUser(user_name_or_id) newSecurityManager(None, user.__of__(app.acl_users))
Editing Objects
So what do you do if you want to edit objects and make the changes persist? Pretty much just treat objects like you'd normal do in a python script. Just when you're done, make sure you issue the following commands.
import transaction transaction.commit() app._p_jar.sync()
Automatically Pack The ZODB
- Add Products.ClockServer to your egg section in buildout.cfg
- Add something like this in your instance section
zope-conf-additional = <clock-server> method /pack_it_all period 86400 user admin password password host localhost </clock-server> - Re-run buildout
- Start server
- In the root of zope, create a "Script(Python)" with the id of "pack_it_all"
- To the contents, add something like this,
dbs=context.Control_Panel.Database names = dbs.getDatabaseNames() for name in names: if name != 'temporary': dbs[name].manage_pack(days=3) print "packed %s" % name return printed - This will pack all the databases you have in Zope once a day
Backing Up Plone
Installation
- apt-get install rsync
Create SSH Keys
backup file
#!/bin/sh # # ZODB # PYTHON_DIR=/home/plone/Plone-3.1/Python-2.4/bin/python REPOZO_FILE=/home/plone/Plone-3.1/zinstance/bin/repozo ZODB_FILE=/home/plone/Plone-3.1/zinstance/var/filestorage/Data.fs REMOTE_USER=nathan REMOTE_HOST=76.222.67.149 REMOTE_PATH=/home/nathan/plonebackups/linode/datafs LOCAL_PATH=/home/plone/Plone-3.1/zinstance/backups/ echo "backing up plone zodb" $PYTHON_DIR $REPOZO_FILE -Bvz -r $LOCAL_PATH -f $ZODB_FILE echo "using rsync to backup to home server" rsync --delete -azvv -e ssh $LOCAL_PATH $REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH echo "completed successfully" # # BUILDOUT # LOCAL_BUILDOUT=/home/plone/Plone-3.1/zinstance/buildout.cfg REMOTE_BUILDOUT=/home/nathan/plonebackups/linode/settings/buildout.cfg echo "backing up buildout" rsync --delete -azvv -e ssh $LOCAL_BUILDOUT $REMOTE_USER@$REMOTE_HOST:$REMOTE_BUILDOUT # # PRODUCTS # LOCAL_PRODUCTS=/home/plone/Plone-3.1/zinstance/products REMOTE_PRODUCTS=/home/nathan/plonebackups/linode/products echo "backing up products" rsync --delete -azvv -e ssh $LOCAL_PRODUCTS $REMOTE_USER@$REMOTE_HOST:$REMOTE_PRODUCTS # # eggs # LOCAL_EGGS=/home/plone/Plone-3.1/buildout-cache/eggs REMOTE_EGGS=/home/nathan/plonebackups/linode/eggs echo "backing up eggs" rsync --delete -azvv -e ssh $LOCAL_EGGS $REMOTE_USER@$REMOTE_HOST:$REMOTE_EGGS
Cron Jobs
- crontab -e
- 0 3 * * * sh /path/to/script
Use Custom Fields in Smart Folders Plone 2.5
Content Type
You'll need to make changes to the fields in your content type.
StringField('firstName',
widget=StringWidget(
label="First Name",
),
index='FieldIndex:schema',
);
The part in bold is what you'll need to do for your field in the content type.
Site Setup
Next you'll need to specify in site setup of your plone instance that you want smart folders to use it.
- Go to site setup
- Click "Smart Folder Settings"
- Select "smart folder metadata" tab
- Click "all fields"
- Find the field you just added and give it a new name(by default it uses its getter name)
- Save

