People either continue to write software in Python 2 or they pick another language that did not shoot itself in the face.

I have been building applications and services in Python 3. I’m not blown away by it. It is very similar to writing software in Python 2, except that there is a much smaller pool of 3rd party libraries available.

…

There are other solutions, but reviving Python 2 is so obviously the correct thing to do, that other solutions are not worth mentioning.

Clearly not everyone agrees that re-focusing on Python 2 is a good idea.

Brython is designed to replace Javascript as the scripting language for the Web. As such, it is a Python 3 implementation, adapted to the HTML5 environment, that is to say with an interface to the DOM objects and events.

That is a trip. Practical? Probably not. Definitely neat though.

The brython.js code that does all the heavy lifting is only 175,936 bytes.

The OpenWest Conference is happening May 2-4, 2013 (formerly the Utah Open Source Conference) at Utah Valley University in Orem, Utah.

This year the keynote speakers are Rasmus Lerdorf, creator of PHP, and Mark Callaghan, lead of the MySQL engineering team at Facebook.

For my part I’ll be giving three different presentations this time around. First up is “Simple Filesystems with Python and FUSE”, where I’ll cover the basics of getting a simple filesystem up and running written in Python using the FUSE library. Next up is “Site Testing with CasperJS”, which is an intro to using CasperJS to run user tests against your site. Last, but not least, is “Scaling WordPress”, where I’ll talk about some of the methods that WordPress.com (the largest WordPress install in the world) uses to host tens of millions of sites that add up to billions of page views per month.

I tried to keep my session titles direct and to the point. At times there will up to ten sessions running at once ( OpenWest session schedule ), so I wanted people to be able to tell at a glance what my sessions are about.

Tickets for OpenWest are available at $80. Every open source group in the area has been given a discount code though, so you can bring that down significantly.

Assuming you have FUSE with Python bindings already working on your system you can download this and start trying it out in three easy steps:

mkdir /tmp/wpcomfs

python wpcomfs.py /tmp/wpcomfs/

mkdir /tmp/wpcomfs/sites/en.blog.wordpress.com

After those steps you’ll have read-only data for en.blog.wordpress.com available at /tmp/wpcomfs/sites/en.blog.wordpress.com.

The mount point /tmp/wpcomfs and the site en.blog.wordpress.com are just examples. You mount wpcomfs where ever you’d like and you can expose public data for any public site hosted on WordPress.com. Since there are millions of sites hosted at WordPress.com wpcomfs will only load data for sites that you mkdir.

This also works for WordPress.com sites that are using mapped domain names. For instance mkdir /tmp/wpcomfs/sites/gigaom.com will provide you with a filesystem layer for GigaOM.com.

Data

When you mkdir a site you get site data, recent posts, and recent comments. In order to keep interactions with the filesystem responsive this data is only loaded once, when mkdir is run. Running rmdir /tmp/wpcomfs/sites/en.blog.wordpress.com will remove the site data.

All of the dates exposed for files and directories in wpcomfs are based on when the site data was loaded. Basically when mkdir was run for the site.

You can mkdir as many sites as you want. I haven’t tested an upper limit, but I imagine if you load enough of them your system will run out of memory and die.

Bugs

I have noticed a few bugs. Specifically, in some cases post content runs into some encoding issues and doesn’t get exposed properly at the filesystem level. Another one that I’ve seen is that the comment count number doesn’t show up correctly. Both of these are issues in the Python code that I need to take the time to work out.

While not really a bug, there are also some patterns in this code that I’m not entirely happy with. I’m hoping with a bit more Python experience I’ll be able to simplify those.

That led to hooking up FUSE and Python to provide the ability to mount the people.get data as a filesystem. A bit more hacking and gplusfs was born. It is still basic, but has been working fine so far with my profile. This is all still read-only, since the Google+ API is read-only.

For JSON values that are strings I used the key name for the file, with an added .txt extension. The size of the file is determined by the length of the string. It works the way you’d expect:

> more displayName.txt
Joseph Scott

For the profile image the API provides the URL of the image, gplusfs grabs a copy of the image and exposes that to the filesystem instead of the URL string.

The other special case is list values, which are exposed as directories. The JSON data provides multiple values for these, so breaking these out as separate directories with their own files seemed like the path of least surprise.

The source code is available at https://github.com/josephscott/gplusfs and configuration wise it just needs your Google+ user id and an API key. Give it a spin and let me know if you run into any issues with your profile data.

The ability of strtotime to slice and dice dates and intervals can be a life saver. I highly recommend taking 10 minutes to try it out.

I was really disappointed to see that strtotime was not part of the Python “batteries included” approach. Fortunately there are Python implementations of strtotime, but really it is so amazingly handy that it should be up for strong consideration as a core feature.

Last night I tagged version 0.3.0 of pressfs, which includes read only support for media files managed by WordPress. You access these files via the new top level directory: /media. Entries in /media look like:

-r-------- 1 joseph root 47487 2010-08-03 20:52 boat.jpg

Copying media files is as easy as cp /var/wp/media/boat.jpg /tmp/boat.jpg

To support read only media files I added two new methods to the pressfs WordPress plugin: get_media_list and get_media_file. The new get_media_file method is a bit different in that it does not return JSON, instead it returns the raw data of the file.

There are still some questions about the best way to structure this data for WordPress installs that have a large number of media files. For now I just wanted something functional that people could use.

When I first announced pressfs I knew that write support was going to come up as a requested feature. As I mentioned in that post, before I made the initial release I’d already been working with write code. After more testing and code clean up I’ve updated pressfs to version 0.2.0, which has (very) limited write support.

And by limited, I mean really, really, really limited.

There are exactly two things that you can edit using pressfs in version 0.2.0: post content and a the url value for a user account (under contact info). Example paths for these looks like:

/var/wp/users/LOGIN/url /var/wp/posts/POSTID-POSTNAME/content

I knew that post content was something people wanted to be able to edit, and adding another field that wasn’t related to posts made me think about how to properly abstract the code that determines which files are writable.

While I’ve tested this repeatedly against my dev install of WordPress, I can’t stress enough that you need to be careful. Read only is pretty safe, with no real way to mess up your WordPress install. Now that we are venturing into the write waters the code needs more people to test it before I’d consider it safe.

Now, with that out of the way, go give this a try – the pressfs code is available on github. Creating a new mount point is easy enough, and I recommend using a non-root account to do it. If your uid is 3000 it is as simple as:

python pressfs.py /var/wp/ -o uid=3000

And if you do find a problem, use the -d option to have pressfs run in the foreground, it will display filesystem activity and python errors.