Personal tools
You are here: Home Weblog Archive 2006 July

Entries For: July 2006

2006-07-31

When a product reinstall fails...

Filed Under:

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.

2006-07-30

Tutorial on integrating z3 tech into Plone

Filed Under:

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

2006-07-27

Adding a new view method to a portal type

Filed Under:

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)

2006-07-24

Using z3 style events

Filed Under:

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__.py :

def addedATDoc(ob, event):
    print "called"
    print ob
    print event

Now add a configure.zcml file with the following content:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five">

<subscriber
      for="Products.ATContentTypes.interface.IATDocument
         zope.app.container.interfaces.IObjectAddedEvent"
         handler="Products.specialevent.addedATDoc"
/>

Start zope in debug mode (with zopectl fg) and watch the terminal when a Plone Page is created. Only problem with this method is that it's zope-wise, instead of being site-wise. localevent is a product that should help with that.

2006-07-22

My favorite development environment

Filed Under:

I thought I'd add some words about the development environment that I feel most comfortable with.

First, I use AGX for most of my plone development. It's useful as a quick skeleton generator, but also as a way to structure the content. To generate the UML files I use Poseidon Community Edition. Up until recently it was buggy, and I still consider it to be, but I learned what to do so I won't trigger the bugs (quick tip: don't ever rename tagged values, delete it and recreate it. If you rename a tgv, it will rename that tgv in the entire model). I've tried ArgoUML and, despite having better support for AGX, it felt buggy. And I don't like the way you have to hunt down the tgvs in that long list when adding one.

I use JEdit as text editor. It's not the greatest python editor, but it's a good all-arounder. I like its xml support, it's great when editing page templates. It's fast, has a ton of plugins and a nice "hypersearch" bar that you can place at the top and use it to quickly search in the curent document. Lately I've started using SPE for a wxpython based project, and I'm also trying Eclipse with pydev.

When creating a plone skin, the Firefox Dom Inspector is invaluable.

I use Ubuntu Dapper as the main OS. Although I have dual boot, 99% of the time I spend it in Linux. It has been my main OS since Breezy Badger came out, and I like it a lot. It runs Java software really fast and Gnome is terific DE. I was a KDE (with WindowsMaker as window manager) fan until my first contact with Ubuntu. It's nice! I bind alt + 1, 2 and so on to the each desktop and so I can switch really fast to the application I'm interested in. I put Jedit on desktop 1, the gnome terminal on desktop 2 and firefox on desktop 3. I can run Internet Explorer 6 and Photoshop 7, to cover even the last Windows needs.

And last, I listen to Radio Paradise with Rhythmbox. When I feel like exploring, I use StreamTuner or head over to Radio Grassy Hill, BorderRadio or Deviant Audio. Either that, or listen to my extensive collection of Grateful Dead mp3 recordings.

2006-07-21

How to access directly fields and widgets from an Archetypes content

Filed Under:

There are two ways to access the field values and widgets from inside an AT content item.

First, a more complex example on getting fields and widgets properties using self.schema:

for fname in self.schema.keys():
    field = self.schema.get(fname)
    widget = field.widget
    widgetLabel = widget.Label(self)
    fieldValue = field.get(self))

To get a field value, one could use

 self.schema['customer_copy_to'].get(self)

The second way uses self.Schema() and shows the equivalent of the above example

self.Schema().getField('customer_copy_to').get(self)

Of course, there's always the default generated AT getters, but sometimes it's not possible to use those (for example, when you want to get the raw value of a field.

How to use at_post_create_script to with multi-schemata content types

Filed Under:

When using at_post_create_script to hook up in the "post creation" events of AT, if the content type has multiple schematas, the script will be called each time the "next" button is pushed.

To properly use the script, a check can be added to see if the "save" button was pressed:

security.declarePrivate('at_post_create_script')
def at_post_create_script(self, **kwargs):
    if self.REQUEST.get('form_submit', None) == 'Save':
        pass   #do something here

       

Weblog
Atom
RDF
RSS 2.0
Powered by Quills
Technorati
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: