Personal tools
You are here: Home Anton's Blog
Document Actions

Anton's Blog

2008-12-03

Test post

Testing topics - why don't they show up in ScribeFire?

I've added some new topics to this blog, but the ScribeFire list doesn't show them. So I thought I'd see whether its being fed by the unique values in the catalog. So nothing to see here, move along please.

2008-11-05

First impressions of nginx with Plone

Filed Under:
After doing something stupid to my apache2 instance on a Ubuntu virtual host, and trying for a couple of hours to get it to start again, I finally got fed up and decided to give nginx a go instead.

OMG! Where have you been all my life? It took 5 minutes!


# sudo apt-get install nginx
# sudo vi /etc/nginx/sites-available/default


Setting up a virtual host for Zope takes *5 lines*:

server {
server_name alt-option.net altoption;
location / {
proxy_pass http://127.0.0.1:8071/VirtualHostBase/http/altoption:80/foo/VirtualHostRoot/;
}
}


# sudo /etc/init.d/nginx start


Done! And the performance seems better - I got into this whole mess because I couldn't run buildout to set up a new plone3 instance at the same time as running zope/apache2 dovecot and postfix. But just managed to do it (so, anecdotal evidence only).

# sudo apt-get purge apache2 apache2-common

2008-10-05

If in doubt...

Filed Under:
Note to self. Stop wasting time with voodoo debugging:

import pdb; pdb.set_trace()

bin/zopectl fg

r (return from current function)
n (next)
list (show where in the code you are)
c (continue)


Do it!

2008-06-18

One line search and replace with perl

Setting up a development version of a website which is littered with absolute URL references could be a particularly time consuming task. But with the following one liner, you can recursively search and replace a whole directory to replace 'oldstring' with 'newstring':

perl -p -i -e 's/oldstring/newstring/g' `grep -ril oldstring *`

There are more varieties available, but this one is definitely my favourite.

2008-03-16

Quills: Can't pickle objects in acquisition wrappers

Filed Under:
I've been wondering for a while why I couldn't update Quills from 0.9 to 1.5. The error message I got was logged on the Quills issue tracker, and has been resolved. All you need to do is remove 'getCategories' from the Indexes and Metadata pages of your portal catalog.

2007-01-08

Rebuilding plone's catalog by walking the site's content

Filed Under:
This changeset to plone, done as a part of 2.5, shows how to walk a plone site's content and rebuild the portal_catalog from it. Could fix a little issue I'm having with duplicate entries on a client site.


powered by performancing firefox

2006-12-16

Moodle installation docs

Filed Under:

2006-10-30

Developing Plone Products Using Z3 Technologies

Filed Under:
To be read. A good step-by-step explanation of how to add Z3 technology to an existing product (ATAudio).

2006-10-23

Setting content dates

Filed Under:
To set the date of a particular piece of content, you just need to call something like the following:

obj.setModificationDate(date)
obj.setCreationDate(date)
obj.setEffectiveDate(date)
obj.reindexObject()

So next, I just have to add it to the migration script I posted to this blog recently



powered by performancing firefox

2006-10-05

Graffletopia

Filed Under:
Great resource for OmniGraffle stencils. Particularly love the Mars Lego stencil.

http://graffletopia.com

2006-10-04

Migration script - thanks Andreas :)

Filed Under:
Thanks to Andreas Jung for posting a simple 'cp -r' implementation for Plone content. Now all I have to do is to:
  • Add support for additional types
  • Synchronise ownership, creation date, etc on copy
  • Replace the local copy stuff with an XML-RPC invocation
And I can migrate content between sites & versions the easy way :)

Here's the script (in case I forget where I put it):

# a cp -r implementation for Plone (basic functionality)


import os
import transaction

srcDefault = '/OK/teaching/test/WS06'
destDefault = '/OK/teaching/test/ws06new'

typesD = {
    'Folder' : 'Folder',
    'File' : 'File',
    'Document' : 'Document',
}

def _c(s):
    try:
        return unicode(s, 'iso-8859-15').encode('utf-8')
    except:
        return s

def createDirStructure(root, dest_path):

    current = root
    for id in [p for p in dest_path.split('/')[:-1] if p]:
        
        o = getattr(current.aq_inner.aq_base, id, None)
        if o is None:
            current.invokeFactory('Folder', id=id)
        current = current[id]

    return current


def cloneTree(self, srcPath=srcDefault, destPath=destDefault):

    src = self.restrictedTraverse(srcPath)
    dest = self.restrictedTraverse(destPath)
    root = self.restrictedTraverse('/')
    unhandled = []

    if len(dest.objectIds()) != 0:
        raise RuntimeError('Destination folder must be empty')

    for i, (path, obj) in enumerate(self.ZopeFind(src, search_sub=1)):

        print '-'*80
        portal_type = obj.portal_type

        if not portal_type in typesD.keys():
            print 'Omiting %s at %s' % (portal_type, path)
            continue

        rel_path = path.replace(srcPath, '')
        dest_path = os.path.join(destDefault, rel_path)
        print i, path, portal_type, obj.absolute_url(1), '->', dest_path
        print 'Creator', obj.Creator()

        destFolder = createDirStructure(root, dest_path)
        destFolder.invokeFactory(typesD[portal_type], id=obj.getId())
        newObj = destFolder[obj.getId()]
        print 'New %s created at %s' % (typesD[portal_type], newObj.absolute_url(1))

        # common fields
newObj.setTitle(_c(obj.Title()))
        newObj.setDescription(_c(obj.Description()))
# newObj.setSubject(obj.Subject())

        if portal_type == 'File':
            newObj.setFile(str(obj.data))


        elif portal_type == 'Document':
            newObj.setText(_c(obj.text))
            format = obj.text_format
            if format == 'html':
                newObj.setFormat('text/html')
            elif format == 'plain':
                newObj.setFormat('text/plain')
            else:
                newObj.setFormat('text/structured')

        else:
            unhandled.append((portal_type, path))

        if i % 10 == 0:
            transaction.commit(1)

    print '='*80
    print 'Unhandled objects'
    for pt, path in unhandled:
        print pt, path

    print 'Finished'
    return 'Finished'

2006-09-06

Plain Blue

Filed Under:

A simple CSS & XHTML web template focusing on whitespace and its importance (from oswd.org)

How To Configure LDAP on Linux

Filed Under:

There's a walkthrough here (http://www.howtoforge.com/linux_ldap_authentication) which describes the process of setting up LDAP on a linux box. Must try and get it working and test out PlonePAS with it :)


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: