The Occasional Occurence

Collection Implementation for CherryPy 2.2

November 07, 2006 at 08:14 AM | categories: Python, computing, cherrypy, General

Inspired by wsgicollection, I cooked up a collection implementation for CherryPy 2.2.x. Here is the docstring for the base Collection class:

A class representing a collection of items.

Items can be created, updated, viewed, listed and deleted.  Dispatches
based on HTTP method and URL fragments.

Classes that need to implement collection-like behavior should inherit from
this class and supply Python method for handling desired HTTP methods.

Something to be aware of is that handlers for the various collection
operations are not "exposed" in the traditional CherryPy sense.  Instead,
they are mapped in the following manner:

HTTP methods meant to operate on the collection and individual collection
items are mapped to handlers in the col_dict and item_dict class attributes,
respectively.

When a GET request is made for a resource identified by a noun like
/creator_page, a "get_creator_page" method is looked up in the collection
object.  The same thing for a PUT request to /45;metadata - a handler named
"put_metadata" would be looked up in the collection object, and the item
number would be passed in as the first argument to the method.

LIMITATION: only integer item IDs are supported.

The soon-to-be-released CherryPy 3 should make this type of dispatching even easier, but sometimes it's fun to teach an old dog new tricks ;-)

cw

New Version of BuffetMyghty

August 25, 2006 at 08:34 PM | categories: Python, cherrypy, General

I just released a new version of BuffetMyghty: 0.3

As I mentioned in a previous post, the main changes are improvements that were made in the Pylons fork of the plugin. All of the Myghty options are able to be passed to the plugin now, and fragments are supported.

Additionally, I wrote a very basic set of unit tests that at least proves that basic functionality works.

Maybe a standard unit test should be made for the plugin interface in general? Basically to assert that a certain plugin provides all of the required functionality. Hhhhmmm...

cw

Buffet 1.0 - A flexible templating filter for CherryPy

August 12, 2006 at 08:57 PM | categories: Python, cherrypy, General

I released Buffet 1.0 today. No huge changes from 0.9, but a couple decent accomplishments.

Unit Tests One of my goals for releasing a 1.0 version was to have unit tests for Buffet. Well, they are in there now. If nothing else, I feel a lot better about the code now that it has to jump through some basic hoops :-)

Flexible Configuration In 0.9, Buffet would look in your CherryPy config file for a section called "plugin_name_settings". These config entries were then passed on to the template plugin in question.

The main problem with that approach was handling multiple apps within a single process. Say you wanted to host two apps using BuffetMyghty and have to separate Myghty component_roots. Well, it wasn't possible, because both instances of the buffet.TemplateFilter would look for a myghty_settings config section and pass the settings found there to the BuffetMyghty plugin.

Now, you can pass an optional config_section parameter to the TemplateFilter's constructor. You can specify a Myghty component_root in a config section called 'app1' and another in 'app2' and pass the section names respectively to each app's TemplateFilter and have individual configurations.

For backwards compatibility, config_section defaults to the old "plugin_name_settings" convention.

Other Changes Buffet is now a CherryPy 2.2.x filter. If you need to use it with a 2.1.x application, you can use version 0.9. The configuration change is the main difference and it doesn't apply as much to 2.1 anyhow since it is not as friendly for hosting multiple apps in a single process.

One thing that I mentioned as a goal for 1.0 but that I didn't implement was profiling. It seemed a bit overkill for the sort of templating middleware that it is. The biggest potential performance hits are going to be on either side of Buffet (controller logic and templating logic). If anyone thinks having profiling is a big deal, feel free to convince me :-)

Finally, in case you missed my earlier posting, Buffet is now housed in a public subversion repository. Thanks Webfaction!

p.s. - Be on the lookout for an improved version of the BuffetMyghty plugin when I get the time to release it! I'm rolling some changes back in from the fork of the plugin used in Pylons. For now you can peek at the code in svn.

Buffet in Subversion

May 25, 2006 at 10:40 AM | categories: Python, cherrypy, General

I haven't done much with Buffet lately, as it has been working fine for me. There have been a few people who have sent me patches for Buffet, so I figured I should get it in Subversion. Thanks to the artist formerly know as python-hosting.com, I've done that. I still need to get some tests written like I blogged about a long time ago, but that will have to wait until after the move and the settling process.

cw

Server Migration Details

May 11, 2006 at 07:36 AM | categories: Python, computing, cherrypy, General

If you are reading this, it means I successfully migrated dowski.com to my new server.

The whole server conversion wasn't too painful. I got my new VPS (Virtual Private Server) from VPSLand last Friday. I only had a few OS choices, none of them being Slackware, so I went with Debian (my other choices were Fedora Core, CentOS, Gentoo or RedHat 9). The server setup took about 36 hours, which seemed a bit long to me.

Debian Linux is pretty nice. I have messed with it a little bit in the past, but most of my experience with Linux has been on Slackware. I like apt-get for managing software and I think I'll like aptitude once I figure out why it sometimes lets me install stuff and doesn't other times.

Moving my blog was a breeze. I backed up my database with mysqldump, copied it to the new machine, ran "cat dbbackup.sql | mysql -p dbname", moved the Wordpress files, edited db username and password for the new machine, and setup a new virtual host in Apache 2. I also had to move my rewrite directives for pretty URLs. I am surprised that there hasn't been a syntax change between Apache 1.3 and 2.

Moving my projects site was super easy as well. The projects site runs Brockman, a CherryPy application I wrote. To move it, all I had to do was move the application directory, get the necessary Python modules installed, start the CP app server and proxy requests from Apache to the CP server.

For email, I decided to give Google's "hosted" Gmail a spin, so I'm not hosting my own email. That is actually kind of nice, because I get to keep my dowski.com email address but use all the great features of Gmail. It also takes some load off of my VPS, which only has 96MB of RAM allotted to it.

I am hosting my own DNS and got free secondary DNS from Twisted4Life. However, my domain registrar has a stupid control panel that is keeping me from using ns1.dowski.com as a nameserver. Thus, my DNS setup is not quite complete yet.

So there you have it. I'm sure there are going to be some "404 Not Found" casualties for some stuff, but hopefully I'll get it sorted out in the coming days and weeks.

cw

« Previous Page -- Next Page »