Plone Migrator is … Gone?

•June 17, 2009 • 11 Comments

Update: I’ve submitted a tutorial for review in the Plone docs.

I’ve been going through the process of moving some local packages into the collective.  In the process of doing so, I’ve changed the names of the packages to make them more general-use friendly.  Now that I’m done with that, the plan was to write some migrations to move the existing objects over to the collective types.

I get working on my migration, using Martin’s helpful guide, and am faced with this:

ImportError: No module named migrator

Well, that’s weird, I must have a broken package.  I go look in the Products.ATContentTypes.migration package, and there is indeed no file called migrator.  Delete the package and run buildout again, still not there.

Googling around points me at the new transmogrifier package, which looks like it will fit my needs nicely.  After working with it a couple of weeks, I can say that I just don’t have the time to figure out how to make this work right now.  I can see that it’s going to be a great package, but I’m on a time crunch here.

More looking, and I happen upon a plone news update on the plone.de site that says, “Removed the migration tool. Upgrades are handled by GenericSetup alone.”  So far, I’ve come upon this slideshow from Six Feet Up explaining upgrades in GenericSetup.  Please, someone tell me if I’m on the wrong track or if you know of a step-by-step tutorial on upgrades.  I feel like I should be done with this by now, but I keep starting over.

This is not Prom

•June 16, 2009 • 2 Comments

DancersOne of the places that I go dancing tends to be … difficult … sometimes.  People tend to dance only with people that they know, and I sometimes only know one or two people.  (Yes, I know that I should make friends, but the leads are out dancing most of the time.  I do make friends with follows.)

I had a couple of not very good dances initially.  One that from first few steps, I recognized as a student of one of the local schools – I have a hard time dancing with students from that school.  I’m not especially skilled in the far-away nuevo style, but can usually get by with a good lead.  These students and their teacher, however, do this style with little or no connection, and I end up feeling thrown around, as was the case here.  The next was with someone that I had danced with before, but had gotten considerably worse in the six months since I had last danced with him.  “I can’t tell what foot you’re on.”  Indeed.

I don’t think of myself as a tango snob, I usually dance with one or two beginners, and often enjoy such dances because they are having so much fun.  Beginners bring fresh energy to a room.

By the time I was asked again, I was eager enough to accept a dance with someone that had just come in, and hadn’t yet observed dancing with anyone.  This guy had clearly not had even one lesson.  He seemed to think he was at prom, just stood there and rocked back and forth.  He put his hand lower than he should have.  When he did make a movement that I thought was a step, his leg was in the way, and I clipped my toe with a heel.  I went and sat down after one song, and he followed me.  He sat down next to me, and put his hand on the back of my chair.  He proceeded to sit there through the rest of the tanda talking about foot massage and asking if I had a boyfriend.  He asked me to dance again at each following song, and I turned him down each time.  I tried to watch the other couples dancing, but had a hard time concentrating.  Finally, he appeared to get bored, got up abruptly, and walked off without a word.

So, good readers, what should I have done?  This is a combination of the baby-sitter and perv types.  I had already walked off the floor, but this was apparently not enough.

easy_install PIL – Not so Easy

•June 9, 2009 • 5 Comments

For some reason, the Python Imaging Library doesn’t seem to easy_install from pypi.  Fortunately, Martin Geber found the solution.

I get this when I try to easy_install PIL:

$ easy_install PIL
Searching for PIL
Reading http://cheeseshop.python.org/pypi/PIL/
Reading http://www.pythonware.com/products/pil
Reading http://effbot.org/downloads/#Imaging
Reading http://cheeseshop.python.org/pypi/PIL/1.1.6
No local packages or download links found for PIL
error: Could not find suitable distribution for Requirement.parse('PIL')

Try this instead:

$ easy_install --find-links http://www.pythonware.com/products/pil/ Imaging

Thanks, Martin!

Support the Rights of the Disabled

•May 29, 2009 • Leave a Comment

Virtualenv in Plone

•May 22, 2009 • 1 Comment

Virtualenv has been recommended to me on several occasions, particularly when I was having issues with my Python install on my MacBook.  I was having some trouble wrapping my head around it, and never seemed to be able to get it to work.  The main thing I was missing was the “activate” command.

I never seem to have Python 2.4 as the main Python on the machines I use anymore.  If I forgot to use python2.4 when running bootstrap.py the first time, it would lead to a chain of predictable errors and some frustration.  Frustration because I knew what I had done, and that it had happened yet again.

Enter virtualenv, the virtual environment.

Create a virtualenv environment suitable for Plone:

$ virtualenv -p /usr/bin/python2.4 plone

The -p option lets you specify which Python command to use within the virtualenv.  This command created a folder named plone.

Browse inside the plone/bin folder and take a look at the activate file.  When you source this file, all of this is run.  Add any extra path or alias information you might need in here, in the same format you would use in your shell.

Let’s take a look at what this file does to your shell.  (I am running Ubuntu Jaunty Jackalope)

$ cd ~/plone
plone$ python -V
Python 2.6.2
plone$ which python
/usr/bin/python
plone$ source ./bin/activate
(plone)plone$ python -V
Python 2.4.6
(plone)plone$ which python
/home/liz/plone/bin/python

Note the (plone) at the start of the prompt, use this to remind yourself that you are operating inside a virtualenv.

Now we have a default python that is the version we want, without effecting the rest of the system.  What else might we want to handle locally?  How about grabbing the PIL?

(plone)plone$ easy_install --find-links http://www.pythonware.com/products/pil/ Imaging

That gets us a copy of the pil that only lives in the virtualenv.  You can see it in ~/plone/lib/python2.4/site-packages  This sort of thing is very useful if you need to have several versions of a package on your box, or just want to try out a package and not worry about having to uninstall it.

You can work with Plone stuff either in this directory, or in another location.  I tend to put everything Plone related in my Plone directory for organization purposes, but the virtualenv will work the same no matter where your code lives on your box.

A Trip to the Melting Pot

•April 20, 2009 • 1 Comment

I have a bit of an anniversary around this time, and decided to go to the Melting Pot to celebrate.

The Melting Pot is a chain fondue restaurant.  It’s a little pricey, so not something you would do very often.  The food is also extremely rich.  We started with a very nice spinach and artichoke cheese fondue, with bread, apples, and veggies to dip in.  I had a very nice California salad to follow, then came the main course.  This included lobster, fillet mignon, duck, sirloin, and chicken.  For dessert, white and dark chocolate swirled together, with fruit and sweets to dip.

Afterward, we went for a nice walk around Lower Queen Anne in the warm twilight.  It was a very nice evening, and the perfect way to call an end to a very stressful year.

The Herbfarm

•April 6, 2009 • 1 Comment

Saturday evening, I went to The Herbfarm for the first time.

I had never heard of this place before, and was completely blown away.  This is not the kind of restaurant I typically go to.  The menu is a list of foods you will be served, not a list of foods to choose from.  This was a nine course meal, served over about four hours.

The food is all local, the herbs come from a nearby farm.  On the tour before the meal, samples of the herbs which were used in the meal were given out to smell or taste.  My favorite was the lemon geranium, I’d had no idea that geraniums were edible!  Best quote of the tour, “At The Herbfarm, we control our weeds by eating them.”  They use two potbelly pigs named Basil and Borage as their trash compactors.  Cutest compactors ever :)

Nine courses sounds like a lot of food, but most of the courses were just a bite.  One of my favorite dishes was steel head trout served in an Asian soup spoon.

I tried beef tartare for the first time.  There were apparently some raw egg concerns, so they made a fake egg yolk that tasted like mustard to have with it, instead.  I sampled it before and after the mustard egg, and liked it better without.  The tartare was wonderful, I really enjoyed it.  I was happy that this was one of the larger dishes.

The main course was a trio of local beefs that are apparently of the kobe strain, but raised locally.  They were all wonderful, though very different.  Each piece was a few bites, and a nice amount to keep me from getting overly full.

The food just seemed to keep coming, but at no time did I feel like I had eaten too much.  There was even a small treat given out on the way out the door.  The place is pricy, with impeccable service and wonderful food.  I think it was well worth a treat once a year or so.

What IS That Smell?

•February 20, 2009 • Leave a Comment

I was standing in the kitchen the other day, bustling around while I baked a pizza.  As I wander near the stove, I smell something odd.  It’s a gas stove, so my first thought was that the pilot light was out.  But, wait, there is no pilot light, it’s the kind that lights on demand.  Confused, I call over my landlady from where she is eating at the table, and ask if she smells gas.

She giggles.  This is funny?  Her mouth full, she covers it and says, “I’m eating durian.”

“You’re eating DURIAN???” I demanded.  She giggles again and nods.  “Can I try some?”

For those not aware of it, durian is probably the stinkiest fruits in existance.  I was aware of it, but had never experienced it before.  It is often outlawed in hotels and airports in regions where it grows, because the smell is so offensive to many people.

Durian looks like and has the texture of creamy butter.  The flavor is mild and sweet, and much more pleasant than I expected.  I didn’t like it enough for the smell to be worth it to me, but I did like it.

The smell is reminiscent to the odor they add to gas so that you know if there is a leak, but isn’t quite the same.  I may not have made the association if I weren’t in a house with a gas stove, but there is definitely sulfur in the scent.  I did not think the smell was bad enough for the reputation that it has, but since then have changed my mind.  It lingers, and seems to become worse as it does so.

Another experience to check off my list, but probably not something that I will see out again.

Creating a Plone Egg

•February 10, 2009 • Leave a Comment

I remember having some difficulty creating an egg several months ago.  I’m not sure if it’s gotten easier, or if I was just missing something in the tutorials that I read at the time.  Therefore, I’m creating a step-by-step set of instructions for how I created my first successful Plone egg.  Note that I tried to use iw.releaser, but my easy_install doesn’t seem to like it.  I don’t think it’s an iw.releaser bug, I think I messed up my easy_install.

I’m running on Ubuntu 8.10 Intrepid Ibex.  I used Martin Aspeli’s instructions on the Plone site for this process.

  1. I created my package using paster.
    paster create -t plone collective.types.citation
  2. I got my package working how I wanted it, and ready for a beta release.  This includes passing tests!  Make sure your tests all pass before you create your egg.
  3. Per Martin’s instructions, I moved my setup.cfg file to another location temporarily.
  4. I changed my setup.py to include my docs/* files for the long_description instead of a text string within the file.
    from setuptools import setup, find_packages
    import os
    
    version = '9.01'
    
    def read(*pathnames):
        return open(os.path.join(os.path.dirname(__file__), *pathnames)).read()
    
    setup(name='collective.types.citation',
        version=version,
        description='Citation content type',
        long_description=''.join((read('docs', 'README.txt'),
                                                  read('docs', 'HISTORY.txt'),
                                                  read('docs', 'INSTALL.txt'),
                                                  read('docs', 'CUSTOMIZATION.txt'),
                                                  #Add any additional files in your docs folder here
                                                  )),
        ...)
  5. I updated my docs/* files with relevant information.  I made sure they were structured with headers and subheaders in the locations I wanted using reST.
    1. One thing that took me a big to figure out was the structure for code within the docs/* files.  If you want to include some code, put a double colon :: on the line before your code.  The following line will be code, and should be indented from the previous line.  Where I ran into trouble was in a bulleted list.  The line is considered to start where the text starts after the bullet.
      • This gave me an indentation error:
        * Tell the plone.recipe.zope2instance recipe to install a ZCML slug::
          [instance]
          recipe = plone.recipe.zope2instance
          ...
      • This was valid:
        * Tell the plone.recipe.zope2instance recipe to install a ZCML slug::
           [instance]
           recipe = plone.recipe.zope2instance
           ...
    2. I checked my long_description to make sure the reST comes out valid.
      1. I installed docutils and ran setup to see the output that will show up on the pypi page.  Note that this outputs to an html file which can be opened in a browser, if there are errors, they will show in the file.
      2. easy_install-2.4 doctuils
        python2.4 setup.py --long-description | rst2html.py > longdescription.html
  6. I uploaded my new egg from inside the top level of my package, src/collective.types.citation
    python2.4 setup.py egg_info -RDb "" sdist register upload

    (If you already have an account on pypi, you should be able to log in at this point. If not, you will be given a chance to register.)
    If you don’t want to log in each time, create a .pypirc directory in your home directory, and include this information:

    [server-login]
    username: your-username
    password: your-password

    Not that this is stored plain-text and not very secure.

Notes

I was having an issue with only *.py files being put into my egg, the *.pt, *.txt, and *.zcml files were being ignored.  I searched all around and couldn’t seem to find anyone else with this issue.  Finally, Tres Seaver had the answer.  I needed to do a subversion checkout, and build the egg with that checkout.  I’ve been using git-svn, which doesn’t actually grab the .svn directories.  Apparently, paste uses the information in the .svn directory to determine which files to add to the egg.  After doing a subversion checkout and running the same command in step 6, my egg built beautifully, and even included the docs directory at the top level of my package :)

Thanks, Tres!

Plone Citations

•February 10, 2009 • 4 Comments

I’ve created a new type in the collective for citations.  There are several formats in there, you can add your own if you need more.  I’m calling this a beta because it’s new, but it is acutally re-worked code from myPublicHealth, so it should work just fine.

You can install the egg via easy_install:

easy_install collective.types.citation

Or add the egg to your buildout:

eggs =
    ...
    collective.types.citation

zcml =
    ...
    collective.types.citation