Tuesday, September 25, 2012

Easier log rotation for buildout users


If you are using buildout and the plone.recipe.zope2instance (>= 4.2.5) to create your zope installation, two parameters are available to enable log rotation. For example:
  • event-log-max-size = 10mb
  • event-log-old-files = 3
This will rotate the event log when it reaches 10mb in size. It will retain a maximum of 3 files. Similar direcives are also available for the access log.
  • access-log-max-size = 100mb
  • access-log-old-files = 10
Enjoy!

Saturday, March 26, 2011

Deleting a member from a large site

The other day my client complained about not being able to delete a member from his site. When I tried it, each time it would spin around for a while and then the zeo client would die with ClientDisconnected. When I poked into the code, i discovered that every object in the site was being visited and reindexed in order to clear out any local roles that the member may have on the object. Of course the transaction becomes huge and the zeo client runs out of memory and ends up disconnecting from the server.

So I added a transaction.commit() in the body of the deleteLocalRoles function in MembershipTool.py. This helped somewhat. The zeo client did not run out of memory and was able to stay connected. Although I ended up with a proxy timeout at the browser, Plone was able to plod along and delete the member and when I went back into User and Groups management, the member was gone.

But nobody likes this half-baked "fix" as you can see at

http://www.gossamer-threads.com/lists/zope/cmf/230407

Friday, February 25, 2011

How to import a nested folder structure containing files



Problem

I have a deeply nested folder structure containing file objects (.doc, .xls, .ppt etc.) and I want to import them into Plone


Approach

By declaring file objects to be IDAVAware, we could use GenericSetup to import them, an idea I got from here:

http://reinout.vanrees.org/weblog/2006/09/13/creating-content-with-genericsetup.html


Steps

1. Mark ATFile as IDAVAware by adding the following in your configure.zcml:


<five:implements
        class="Products.ATContentTypes.content.file.ATFile"
        interface="Products.GenericSetup.interfaces.IDAVAware"
   />

2. Create a structure folder under the default profile of your product and create the desired folder structure there.

3. Recursively create the .objects, .preserve and .properties files under the structure folder. To make this easy, you can use the prepare_content recipe from collective.migrator. Your buildout step should look something like this:



[prepare_content]
recipe = collective.migrator:prepare_content
top_folder = /plone/src/my.product/my/product/profiles/default/structure/My Folder Structure/


4. Reinstall your product using the portal_quickinstaller



Wednesday, February 23, 2011

How to export a nested folder structure containing Files



Problem

I have a deeply nested folder structure containing file objects (.doc, .xls, .ppt etc.) and I want to export them to the file system


Approach

By declaring file objects to be IDAVAware, we could use GenericSetup to export them, an idea I got from here:

http://reinout.vanrees.org/weblog/2006/09/13/creating-content-with-genericsetup.html


Steps

1. Mark ATFile as IDAVAware by adding the following in your configure.zcml:

  
   <five:implements
      class="Products.ATContentTypes.content.file.ATFile"
      interface="Products.GenericSetup.interfaces.IDAVAware"
   />

2. Go to portal_setup at the root of the site

3. Go to the Export tab, select the step called Content

4. Click on Export Selected Steps at the bottom

Caveat

A small change in GenericSetup which will land in version 1.6.3 made this possible,

https://bugs.launchpad.net/zope-cmf/+bug/722726


Thursday, November 4, 2010

Removing a file from nginx cache

$ cd <cache-dir>

$ rm -f `grep -rl '^KEY: [^/]*<full-path>$' .`

Tuesday, September 14, 2010

MailHost fails with gaierror: [Errno 2] Temporary failure in name resolution on MacOS

Start your instance as follows:

$ /usr/libexec/StartupItemContext bin/instance start

Sunday, September 12, 2010

Staying logged in over multiple browser sessions


Portal Properties -> Site Properties -> auth_cookie_length

Specifies the validity period of the login cookie.

But just make sure that credentials_cookie_auth is activated in

acl_users -> plugins -> Update credentials plugins.