Clouseau: A new developer tool for Plone

A new developer tool was placed in the Collective. This Ajax tool offers a python prompt similar to running "zopect debug" or breaking into the zope through a pdb call. It is really cool and useful in debugging and exploring Plone. I'd rank this tool as extremely important to the regular Plone developer, along DocFinder or the pdb debugging module. Current location is here:http://svn.plone.org/svn/collective/Clouseau/ [...]

Getting a list of catalog indexes and metadata

I recently had a need to get a list of the indexes from the portal_catalog. While the metadata has an API method to get it, using something along: pc = getToolByName(self, 'portal_catalog') metadatas = pc.enumerateColumns()I couldn't find the equivalent API method to get the Indexes. After digging through the DTML files used by ZCatalog, I came up with the following method: pc = getToolByName(self, 'portal_catalog') indexes = pc.Indexes.objectIds() [...]

Basic unittesting for Plone

Create a new package called "tests" inside the product. Add modules that begin with test*, like testSetup. Next, run the tests with zope/bin/zopectl test -s Products.MyProduct (zope 2.9) from Testing import ZopeTestCase ZopeTestCase.installProduct('DRFSkin') from Products.PloneTestCase.PloneTestCase import PloneTestCase from Products.PloneTestCase.PloneTestCase import FunctionalTestCase from Products.PloneTestCase.PloneTestCase import setupPloneSite setupPloneSite(products=('DRFSkin',)) class TestTool(PloneTestCase): def afterSetUp(self): pass def testProductPath(self): x = True self.failUnless( x ) def test_suite(): from unittest import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(TestTool)) [...]

Getting the real path of a zope product

To get the path of a zope product, one can use the following snippet: from Globals import package_home product_path = package_home(product_globals) [...]

Locked yourself out of zope?

A very easy way to add a user to zope from outside zope: Turn off zope.Run <instance_home>/bin/zopectl adduser username password The user will be added as Owner to the acl_users in the main zope root. [...]

Quick guide to ZopeSkel

Download and run as root ez_installrun:easy_install http://svn.plone.org/svn/collective/ZopeSkel/trunk#egg=ZopeSkel-devcreate a new Plone Core product using paster create -t plone product_name References: http://danielnouri.org/blog/devel/zope/zopeskel-plonecore.htmlhttp://plone.org/documentation/tutorial/using-zope-formlib-with-plone/tutorial-all-pageIn Zope 2.9, the pythonproducts is needed for this or any other regular python package created with setuptools to work. [...]

When a product reinstall fails...

It happened to me several times, and I always forget what the problem is. Sometimes a product reinstall (from QuickInstaller) fails with an odd error: AttributeError: manage_addTool. This only means that the product is broken. Make a visit to the Zope Control Panel \ Products and look in the refresh page for the product on the real reason why it fails. [...]

Tutorial on integrating z3 tech into Plone

There's a tutorial in the collective that shows a bit of how to use z3 tech inside Plone [...]

Adding a new view method to a portal type

While this method is superceeded by GenericSetup, it's usefull enough that I place it here. ptypes = portal.portal_types psite = getattr(ptypes, 'Plone Site') view_methods = psite.view_methods vm = list(view_methods) + ['main_frontpage'] psite.manage_changeProperties(view_methods=vm) [...]

Using z3 style events

Based on my previous entry on at_post_create_script, I was curios on how to achieve something like that using z3 style events. Now, I know that it's not the same and the following events are meant only to replace manage_afterAdd and so on, but I'm pretty sure that there are (or will be) events fired that would replace the at_post_* scripts. So, easy as it gets: Create a new python package inside the zope Products folder, add the following method inside __init__. [...]