December 16th, 2008
As you probably know, I've been working on a Django-based re-build of BostonChefs.com (the new version of which is actually live now, but due to DNS propagation issues isn't yet available to 100% of people which is why I haven't yet written a post about it). Among other things, BostonChefs.com provides information on some of the fantastic restaurants in the Boston area. One piece of information it provides is the hours of operation of those restaurants. In order to store this information I created a model called HoursOfOperation. It looks like this:
class HoursOfOperation(models.Model):
DAY_CHOICES = (
('0', 'Sun'),
('1', 'Mon'),
('2', 'Tue'),
('3', 'Wed'),
('4', 'Thur'),
('5', 'Fri'),
('6', 'Sat'),
)
restaurant = models.ForeignKey("Restaurant")
meal_period = models.ForeignKey("MealPeriod")
day = models.CharField(max_length=3, choices=DAY_CHOICES)
open_time = models.TimeField(default=datetime.datetime.now)
close_time = models.TimeField(default=datetime.datetime.now)
def _get_hours(self):
return "%s - %s" % (self.open_time.strftime('%I:%M%p'), self.close_time.strftime('%I:%M %p'))
hours = property(_get_hours)
As you can see, each 'hour' is related to a restaurant and a meal period, which allows us to display the information in a manner similar to that you might find on a store's front sign. For example, if you go to the Grill 23 & Bar page (my personal favorite restaurant in Boston, although Craigie on Main is a decent challenger), you'll see something like this:
DINNER
* Sun: 5:30 p.m.-10 p.m.
* Mon-Thur: 5:30 p.m.-10:30 p.m.
* Fri: 5:30 p.m.-11 p.m.
* Sat: 5 p.m.-11 p.m.
Building a list like that out of the above model proved slightly more difficult that I might have hoped. It required quite a lot of template logic, including writing a custom filter. The block of template code necessary to generate that list looks like this:
{% regroup restaurant.hoursofoperation_set.all by meal_period as periods %}
{% for period in periods %}
{{ period.grouper }}
{% regroup period.list by hours as hour_list %}
{% for hour in hour_list %}
- {{ hour.list|collapsedays }}
{% endfor %}
{% endfor %}
As you can see, somewhat complex. Those nested {% regroup %}s can be nasty to wrap your head around, if nothing else. But basically it's taking the set of HoursOfOperation objects related to the restaurant, grouping them by meal period, then taking the subset of those objects for each meal period, and grouping those by the hours of the day they represent. So what you're then left with is a list of all the different time periods (still represented as HoursOfOperation objects) that the restaurant is open for a given meal period, and the days on which it is open during those hours. As you can see above, the days are represented by number of the day of the week (0 for Sunday through 6 for Saturday).
Converting that list integers into something like 'Mon, Wed-Fri' was not very easy, and certainly not something I wanted to try to tackle using Django's template tags. I ended up drawing heavily on my hazy memories of CS 127 (many thanks to Dave who taught me all about recursion way back then) and creating a filter that considers the list of HoursOfOperation objects as a list of those integers, then recursively converts it into a list of lists representing the subsets of contiguous days in the list. So if you start out with [1, 3, 4, 5] you end up with [[1, 1], [3, 5]] which is then converted into 'Mon, Wed-Fri'. After several false starts I ended up with this beauty of a Django template filter:
from django.template import Library
from django.template.defaultfilters import time
from types import ListType
register = Library()
def simplify(index, found, days):
high = index+1
mid = index
low = index-1
if not found:
days[low] = [days[low], days[low]]
if high >= len(days):
if not isinstance(days[-1], ListType):
if days[-1] == days[-2][1]:
days.pop(-1)
else:
days[-1] = [days[-1], days[-1]]
return days
if int(days[high].day) - int(days[mid].day) == 1 and (found or int(days[mid].day) - int(days[low][0].day) == 1):
days[low][1] = days[high]
days.pop(mid)
high = high-1
found = True
else:
if found:
days.pop(mid)
found = False
return simplify(high, found, days)
@register.filter
def collapsedays(value):
hours = "%s-%s" % (time(value[0].open_time), time(value[0].close_time))
days = simplify(1, False, value)
for i in range(len(days)):
if days[i][0] == days[i][1]:
days[i] = days[i][0].get_day_display()
else:
days[i] = "%s-%s" % (days[i][0].get_day_display(),
days[i][1].get_day_display())
return "%s: %s" % (', '.join(days), hours)
Tags:
boston,
bostonchefs,
code,
django,
filter,
food,
massachusetts,
programming,
python,
restaurants,
template
|
Comments:
No comments! |
Permalink
December 12th, 2008
Really, this was a pretty major oversight on my part, but I just now finished added a 'status' field to each entry in my blog app. It's a pretty simple thing in and of itself, I just added a tiny bit of code to my Entry model:
STATUS_CHOICES = (
('dr', 'draft'),
('ac', 'active'),
('ar', 'archive'),
)
status = models.CharField(choices=STATUS_CHOICES, max_length=2, default='dr')
And then a custom manager as well:
class EntryManager(models.Manager):
def active(self):
return self.get_query_set().filter(status='ac')
Remembering, of course, to make sure that manager was actually accessible from the model (in this case by adding 'objects = EntryManager()' to my model class).
Once I did that I was able to change the Entry.objects.all() in my view(s) to Entry.objects.active() and now I'm able to write a post and save it without actually publishing! As I said, something of a bonehead move that I didn't do this in the first place.
Since I was messing around in my code anyway I decided to clean up the admin for my Entry model as well. Since I'm the only one who ever uses the admin for my blog, I hadn't bothered to before, but now I've got a little more info available to me when looking at my entries:
class EntryAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
save_on_top = True
list_display = ['title', 'post_date', 'site_list', 'status',]
list_filter = ('sites', 'status',)
So my admin now looks something like this:

A cool thing there is the 'site_list' column. By default, you can't use a ManyToManyField in the list_display for your model. But I've dealt with this before, and it's only 5 lines of code to make this work:
def site_list(self):
if self.sites:
sites = [site.name for site in self.sites.all()]
string = ", ".join(sites)
return string
Good stuff!
November 19th, 2008
Every so often you run into a situation where Django's built-in form fields and widgets just don't meet your needs. I ran into this the other day when creating a credit card processing form. I wanted an easy way for the user to enter the expiration month and date of their card, but the tools provided by django only gave me a single text field and the option to use a javascript date picker. Neither of those was quite what I wanted, I just wanted two selects that would allow the user to pick the month and the year, as on pretty much every credit card form you've ever filled out online.
The obvious option would be to make two separate fields on your model, one for month, and one for year. But I don't really like that option. I would much rather have both selects show up on the same line, which is not the behavior you'd get with two separate fields. So I decided to write a custom widget and field to accomplish this. It was actually surprisingly easy to do. Probably the most difficult part was coming up with a decent way to populate the selects with worthwhile options. I'm not entirely pleased with the route I took there, but it's easy enough to change later. Here's my code:
from django import forms
import datetime
class MonthYearWidget(forms.MultiWidget):
"""
A widget that splits a date into Month/Year with selects.
"""
def __init__(self, attrs=None):
months = (
('01', 'Jan (01)'),
('02', 'Feb (02)'),
('03', 'Mar (03)'),
('04', 'Apr (04)'),
('05', 'May (05)'),
('06', 'Jun (06)'),
('07', 'Jul (07)'),
('08', 'Aug (08)'),
('09', 'Sep (09)'),
('10', 'Oct (10)'),
('11', 'Nov (11)'),
('12', 'Dec (12)'),
)
year = int(datetime.date.today().year)
year_digits = range(year, year+10)
years = [(year, year) for year in year_digits]
widgets = (forms.Select(attrs=attrs, choices=months), forms.Select(attrs=attrs, choices=years))
super(MonthYearWidget, self).__init__(widgets, attrs)
def decompress(self, value):
if value:
return [value.month, value.year]
return [None, None]
def render(self, name, value, attrs=None):
try:
value = datetime.date(month=int(value[0]), year=int(value[1]), day=1)
except:
value = ''
return super(MonthYearWidget, self).render(name, value, attrs)
class MonthYearField(forms.MultiValueField):
def compress(self, data_list):
if data_list:
return datetime.date(year=int(data_list[1]), month=int(data_list[0]), day=1)
return datetime.date.today()
Simple, no? The results end up looking like so:

November 18th, 2008
Django provides an extraordinarily easy way of integrating file uploads into your site in the FileField (also the ImageField which provides some nifty image-specific functionality). However as soon as you start dealing with file uploads you have to worry about where those files are going to be stored. To take care of this, the 'upload_to' argument is set when declaring your FileField which is a local filesystem path that will be appended to your MEDIA_ROOT to the upload location (you could also use an absolute path). By default this is just a static string, though it does handle strftime arguments to allow some flexibility and will look something like this:
def model(models.Model):
file = models.FileField(upload_to='my/file/uploads/')
...
However that's not always going to cut it. Sometimes you're going to want more flexibility that even just separating the files out by date information. In that case you can take advantage of the fact that a callable can be passed as an argument. In one of my projects I've defined a function that returns the appropriate path depending on a couple of different variables. In this particular case, I know that all uploads for a certain model will be PDFs, while all uploads for certain other models will be images, so I'm able to pretty easily generate appropriate paths for those uploads. We also wanted to obfuscate the filenames so that someone couldn't easily guess the path for other files, and didn't really like the way that Django simply keeps appending '_'s to filenames in the event of a filename collision until it ends up with a unique name. To handle that I simply generate a random string to use as the filename, which fits our needs quite nicely. In my specific case, the function lives in myproject.lib.files and looks like this:
import random, string
from django.contrib.contenttypes.models import ContentType
def get_path(instance, filename):
ctype = ContentType.objects.get_for_model(instance)
model = ctype.model
app = ctype.app_label
extension = filename.split('.')[-1]
dir = "site"
if model == "job":
dir += "/pdf/job_attachment"
else:
dir += "/img/%s" % app
if model == "image_type_1":
dir += "/type1/%s" % instance.category
elif model == "image_type_2":
dir += "/type2"
elif model == "restaurant":
dir += "/logo"
else:
dir += "/%s" % model
chars = string.letters + string.digits
name = string.join(random.sample(chars, 8), '')
return "%s/%s.%s" % (dir, name, extension)
As you can see, it's pretty simple to generate an upload path based on pretty much any characteristics you want. To then tell Django to use this function to get the upload path rather than a static string you modify your model definition like so:
from myproject.lib.files import get_path
def model(models.Model):
file = models.FileField(upload_to=get_path)
...
And that's all it takes. Now all my uploads are automatically renamed and uploaded into the particular directory structure that we want. And since all the logic involved is in a single function it's extremely easy to change it at any point if we decide to alter our directory structure.
October 27th, 2008
One of the Django projects that I've been working on for about a year and and will (fingers crossed) be going live in the very very very near future has involved a lot of modification to Django's admin interface. I plan on writing more about the many, many specific changes that I've made to the interface (without modifying the actual Django codebase, so that the changes can be easily applied by anyone without breaking updates), but to talk about them all at once would make far too long of a post. So I'll be taking them on one at a time.
The change I want to talk about right now involves redirecting the user to the page I want them to be at after they've finished adding or editing an object rather than to that object's model's change_list. Normally, if you're editing an Entry object in the Blog app, when you hit save it will take you to /admin/blog/entry/, which is a list of all the Entry objects in the database. However there are some instances in which this isn't the behavior I want. Once such instance involves model inheritance. Say, for example, you have multiple types of Entries which you've accomodated through multi-table-inheritance. Because the different sub-classes are different models, they all have their own change_lists in the Django admin. But I want to be able to view, edit, and create Entries of all types from one page.
Fortunately, Django makes this fairly easy to accomplish. All that is necessary is to override the appropriate methods in the Entry ModelAdmin. That will end up looking something like this:
class EntryAdmin(admin.ModelAdmin):
def change_view(self, request, object_id, extra_context=None):
result = super(EntryAdminAdmin, self).change_view(request, object_id, extra_context)
if not request.POST.has_key('_addanother') and not request.POST.has_key('_continue'):
result['Location'] = iri_to_uri("/admin/blog/entry/")
return result
The exact same modification should be made to add_view as well, and a nearly identical modification to delete_view though it doesn't need to deal with the _addanother and _continue cases. You can then use the EntryAdmin class for all of your varioud Entry sub-classes, or, if you need some other changes to the admin for different Entries sub-classes you can sub-class EntryAdmin for them. Now, whenever you hit the save button after editing any sort of Entry, it will always take you back to /admin/blog/entry/ rather than /admin/blog/linkentry/ or whatever your other subclasses are. If you want it to only take you back to /admin/blog/entry/ if you're coming from a particular page and otherwise take you to /admin/blog/linkentry/ all you need is to add a GET variable to your url (something like '/admin/blog/linkentry/add/?return_to_main=True') and then check for it in your modified change_view, add_view, and delete_view methods with a request.GET.get('return_to_main', False). I've even used this between objects of different model types to create a 'dashboard' page that allows you to view, and alter the relationships between an object of one type with objects of another type. All that's necessary in a case like that is to pass the id of the object in your GET variable and take that into account when creating your uri. An added benefit of that it makes it easy to auto-fill the ForeignKey field when creating a related object. In such a case you'll also need to keep that GET variable in the URLs down the line in order to maintain compatilibility with the 'Save and add another' and 'Save and continue editing' features. But that's still a simple modification:
class EntryAdmin(admin.ModelAdmin):
def change_view(self, request, object_id, extra_context=None):
result = super(EntryAdminAdmin, self).change_view(request, object_id, extra_context)
other_id = request.GET.get("other_id", None)
if not request.POST.has_key('_addanother') and not request.POST.has_key('_continue'):
if other_id:
result['Location'] = iri_to_uri("/admin/dashboard/%s/") % other_id
return result
elif request.POST.has_key('_continue'):
if other_id:
result['Location'] = iri_to_uri("?other_id=%s" % other_id)
return result
elif request.POST.has_key('_addanother'):
if other_id:
result['Location'] = iri_to_uri("%s?other_id=%s" % (result['Location'], other_id))
return result
return result
But more on that sort of thing in other posts.
October 16th, 2008
I've been nothing but impressed with the service I've got from WebFaction and the reliability I've gotten from their servers. I even had a very high traffic site run on a WebFaction shared account without a hitch.
Today, however, we got a first hand look at the downside of a shared server. If you're a webfaction customer you should be (no really, you should) subscribed to their status blog It's a great way to be kept up to date on any issues that might affect your site. The most recent issue has to do with the MySQL server on web49: the server that we happen to be using to develop a very large project. As you can see from reading the entry, the problem appears to have been caused by a corrupted database table (not one of ours) which was causing some unreliability with the database server (our Django based site was intermittently unable to connect to the database and, when it could, intermittently unable to authenticate). Though they thought they had it fixed, the problem returned and while they're attempting to fix it for good they've rolled back the entire database server to a known good backup.
This is a good approach as it means that everyone should still have most of their data in the meantime. Unfortunately, we happen to be in the middle of populating the database with the data we need to go live in the near future. Rolling back the database even by a day means that we've lost a ton of work. We should get it all back once the problem is fixed, but of coruse that means that we have to put the work on hiatus until the problem is fixed to avoid versioning issues.
This right here is the perfect illustration of why a dedicated server is a good idea. Yes, a shared server might be able to support your site. But it also leaves you vulnerable to the actions of the people you're sharing the server with. If someone else does something stupid that corrupts a database table on a server that they share with you suddenly you stand to lose a lot of work. If someone has a poorly written app that somehow manages to crash the server or even just eat up all the RAM, your site goes down. With a shared server you simply don't have the security of knowing that your site is stable and secure even if you trust your hosting company and you trust your code.
That security is what you're paying for when you get a dedicated server over a shared one.
Tags:
dedicated,
dedicated server,
django,
downtime,
hosting,
mysql,
security,
server,
shared,
shared server,
stability,
uptime,
webfaction
|
Comments:
1 |
Permalink
October 13th, 2008
I've been using WebFaction for my hosting for a while now, and have been extremely pleased with them. In addition to the fantastic service I've received, I've been very impressed with the intelligent way they have their servers setup. They've clearly done a lot of work to make things as modular as possible which makes it insanely easy for me to run multiple sites with very different requirements seamlessly on the same server.
Basically what they've done is segment out all of your different websites into 'applications'. Each application in represented as a directory in your ~/webapps/ directory, and is essentially a self-contained environment with it's own apache instance, and, in the case of a Django app, it's own $PYTHONPATH. The end result is that even though all the websites are being stored and run from within my home directory, they're entirely modular, can have different, or different versions of the same, dependencies installed, and can be shut down and restarted independently of one another. On top of all this is a fantastically simple custom web-based control panel that I'm pretty sure is built with Django.
I've been so impressed with how well this setup works, that I've decided to duplicate it on my home server for development purposes. Currently I do pretty much all my development work on my Gentoo Linux powered ThinkPad. To that end I've installed Apache, MySQL, PostgreSQL, SQLite, Python, PHP, &c. to allow me to mimic the live sites as closely as possible and to allow me to continue working when I don't have internet access (such as when I'm flying or visiting Jessi's family out beyond the reach of broadband). This works very well, but as I'm just using a basic Apache install, without any VirtualHosts, it's not nearly as flexible and means I can really only work on a single site at a time with some work necessary to switch back and forth between projects. Of course most of the time I just use Django's built-in development server when working with Django, but I do end up relying on Apache sometimes, and I'd like to set up my home server as a more complete development environment for both myself and some friends I can grant VPN access to. So to that end I've been looking into WebFaction's setup with the idea of re-implementing it myself.
Turns out it's pretty simple. Simple enough that I almost feel like I should have thought of it myself. Basically, WebFaction's setup scripts create a new 'app' in your ~/webapps/ directory, and populate it, most importantly with a copy, owned by your user, of the Apache executable, some scripts to start, stop, and restart that executable, and an httpd.conf file that sets the (in the case of a Python-based app) $PYTHONPATH variable to include a ~/webapps/yourappname/lib/python2.5/ directory allowing each site to maintain it's own dependencies independently (you can also put things in your ~/lib/python2.5/ for global dependencies if you want). Oh, each application also gets it's own copies of the necessary Apache modules to the same effect. Each application's Apache instance(s) is set up to listen to a different (non-80) port. The end result of this is an extremely simple, extremely modular setup that works fantastically.
Obviously I've left out a step here. If each Apache isntance is listening to a different, non-80, port, how does your traffic get to your actual site? This is the one part that I can't really just peek into the configuration files for, because it doesn't (as far as I can tell, which makes sense) live on the same server as my sites. I assume that what's happening is that WebFaction's name servers are simply pointing requests to (for example) joshourisman.com:80 at my.webfaction.server:portnumber. Again, a simple, yet elegant solution that allows for easy customization and expansion.
I haven't yet tried to implement this setup myself (I first want to move my server from FreeBSD to Linux (which now that I'm using full-time again I'm just much more familiar with), but there's nothing about it that's particularly tricky. Really, the routing is probably going to be the hardest part, but I'm planning on replacing our rather lackluster TrendNet wireless router with a Linux box which will give me much greater control and (hopefully) better reliability.
September 24th, 2008
Django provides a lot of really useful tools to simplify the development process and let you focus only on the important bits. The FileField and ImageField (a subclass of FileField) are good examples of that letting you simply tell Django that your model will have a file or image and letting it take care of the issues of uploading, storing, and all that. In the past, that's really been enough. It will even automatically delete the file/image when you delete its parent model object. One thing it doesn't do, however (and this has been the topic of much debate), is delete a previously uploaded file/image when you upload a new one for the same model. What I mean by this is if you have a model with a FileField defined and use it to upload some file associated with an object. If you then later decide that you want a different file associated with that object and upload it, it doesn't delete the original file and instead leaves it in place and only changes the path stored in the database to point to the new file. Depending on the nature and traffic your website gets, this can lead to massive amounts of storage being wasted on orphaned files (assuming you don't want to keep those old files, of course). I toyed with a couple different approaches to this, including the possibility of subclassing the FileField to try and add that functionalty directly to the field. While this would probably work, I instead opted for a less generalized method: overriding the save() method of the model to take care of this:
def save(self, force_insert=False, force_update=False):
try:
old_obj = ModelName.objects.get(pk=self.pk)
if old_obj.image.path != self.image.path:
path = old_obj.image.path
default_storage.delete(path)
except:
pass
super(ModelName, self).save(force_insert, force_update)
This work perfectly, though it has the disadvantage of being specific to a particular model, which violates the DRY principle (assuming you're going to use it on more than one model). Fortunately there's a simple way to solve this problem too: subclassing models.Model and then instead of having all your models subclass models.Model directly, have them subclass your own version of it instead. In that case you'll probably want to have it work generically on all ImageFields and/or FileFields rather than having to name them all specifically. This isn't too hard, and you can build up a list of all the ImageFields for a particular model like this (taken from the sorl-thumnail project):
for field in model._meta.fields:
if isinstance(field, models.ImageField):
if field.upload_to.find("%") == -1:
paths = paths.union((field.upload_to,))
[Edit: There was a bug in my code that I've corrected. Details are below in the comment by Comete.]
[Edit2: Fixed another problem in the code with variable names. Thanks, again Comete!]
September 13th, 2008
I've just implemented the first real benefit of having my blog now be Django based instead of WordPress based. Because part of the reason I had wanted to make this move all along was to allow for some close integration between my blog and my business site, when I went about setting up the Django project for the blog I actually just duplicated the project for my business site. Because of this, I'm able to use Django's sites framework to have both project pull from the same database. This means that any information available to one is also available to the other.
Because I used a ManyToManyField to define the relationship between a blog entry and a site, I'm able to specify that a particular entry is related to either or both of the two sites (as well as any future sites that I may decide to add). This entry, for example, is related to both. Thanks to Django's fabulous templating system I was able to effortlessly integrate the blog templates into my business site without every writing a single line of HTML or CSS.
The end result of all this? The business relevant posts on my blog are available not only at joshourisman.com, but now also at dydxtech.com/blog.
How cool is that?
September 12th, 2008
It's always fun doing this: a new project has gone live! In cooperation with BostonChefs.com, Fresh from the Family Farm is an event for local Boston-area restaurants to showcase the possibilities of local ingredients from area family farms. The event runs from Oct. 12 through Oct. 19, and a list of participating restaurants, along with links to make reservations through OpenTable (where available), and links to the restaurant's BostonChefs.com profile (also where available).
The website is powered by Django (which is now at 1.0, something I plan to write about soon), which even still I am growing to love more and more as I use it.
July 29th, 2008
I've just started working on a new project using ExpressionEngine, a PHP-based content management system. I didn't really know a whole lot about it going in (it was the client's choice to use EE), but from what I've seen so far it's a pretty decent piece of software.
Being a CMS, it sits somewhere between blogging software like WordPress, and a framework like Django. Basically this means that it's much more structured than Django, proving a lot more blogging and related functionality out of the box but still much more flexible than WordPress allowing for a lot more freedom in the creation of your website. So far it seems like they've struck a good balance, providing a relatively shallow learning curve while still giving you a lot of powerful features.
Of course, for me, I found the more structured nature of it to be a bit restrictive. Also, I just don't get some of the choices they made. For example, your URLs, while readable and search engine friendly, all look like 'domain.tld/index.php/blog/archive/&c'. Not a bad URL, but why on Earth is that 'index.php' in there? If they're going to use URL re-writing to provide nice URLs, why do they leave that useless bit of information in there? It's not like it would have been any harder for them to have taken it out. Also, the only obvious way to edit templates is through their web-based control panel. I'm sure there's really nothing stopping me from going in with an FTP client or via SSH and editing the text files directly, but they don't even hint at where you would want to look to do that (and as I didn't install it on the server myself I have no experience with the directly structure). Neither of these problems is a big deal, or a big obstacle to someone who knows what they're doing and wants to change it, but they just seem like very strange design decisions to me.
Overall, however, I think it looks like a pretty good system, and very good way to rapidly build a flexible and highly useful CMS. I don't know that it'll ever be my first choice for a project, as anything I can do with EE I can also do with Django, and in a way that's more intuitive (though probably has a higher initial investment of time), and anything that I don't need that level of flexibility and power for, I'd probably just use WordPress. But still, it's a nice piece of software, and I can definitely see how it would be a very good choice for a lot of people.
July 16th, 2008
As those in the Boston area are probably aware, this years Summer Restaurant Week is fast approaching. This year it will be two weeks, those of August 10 through August 15 and August 17 though August 22. If you've been reading my blog for a while you may know that one year ago, almost to the day (off by 5) I announced that I had helped work on BostonChefs.com's Unofficial Guide to Restaurant Week. Well, this year I'm announcing the same thing.
The site just went live with all the information you might want about what's going on with this Summer's Restaurant Week including the restaurants that are participating, what meals they'll be serving, what's on their menus (where available), and a Google Maps mashup to help you find them. The site has been completely redeveloped and is now powered by Django, making this my first Django-based project to go live! (Not counting my own website, of course.)
Go check it out, and bon appetit!
June 20th, 2008
As I mentioned in my last post, I recently migraded my dy/dx tech website to a different hosting company. If you've really been paying attention, you may recall that not too long ago I had gotten a Media Temple hosting account with the plans on migrating all of the sites I host, both my own and clients' to it only to discover that setting up Django on a Media Temple (dv) account is far more trouble than it's worth. My estimation of that hasn't changed, in fact I actually cancelled my Media Temple account a few weeks ago after the last client I had hosted there was moved off to another host. My experiences with WebFaction have been so positive (exploding data centers notwithstanding), that I have instead migrated everything to their servers. Well, not everything yet. This blog is still hosted on DreamHost for the time being (though I plan on moving it to a WebFaction hosted WordPress blog in the very near future before eventually migrating it to a Django based solution as I've mentioned before).
The hosting hassles referred to in the title, thankfully, have nothing to do with the actual hosting companies I'm dealing with, and are instead due to a foolish mistake on my part: when I switched my domain to WebFaction, I forgot that I had custom MX records enabling the use of my hosted google apps for my domain. As a result, as the new DNS information started propagating, people stopped being able to send me email. Fortunatly, it was an easy fix to just change the MX records with WebFaction, and I don't think I missed any important emails, but if anyone out there got a bounceback when sending me an email, that's why.
June 18th, 2008

It's been a while since I've been able to announce a big new project. Not because I haven't had any, but because everything I've been working on lately has been so large that nothing is quite ready to go live yet. But finally, I get to announce a big project that I recently finished: the Becoming MOBOS video blog. As I'm sure many of you from the Boston area are aware, there is a new Mandarin Oriental that's been under construction down by the Pru. They hired me to create an internal video blog for them. Unfortunately, since it's internal, I can't link to it, but the screenshot to the right links to a full-size, albeit redacted, image. It's a WordPress based blog using a verstion of WPelements.com's MassiveNews theme customized by your truly. I also used FlowPlayer to provide the Flash video playback capabilities. All in all, I think it turned out to be a pretty slick site.
That's not the only news, however. In preparation for announcing the Becoming MOBOS site I've been doing a little work sprucing up my own website. So I also get to announce a new version of the dy/dx tech website (I also changed hosts for it, so you may need to wait for the DNS to propagate if you're still seeing the old site). The overall look of the site is the same as before, but I've removed some rather pointless elements such as the Google Map that used to be on the front page. In it's place is now a slideshow of screenshots from my portfolio, which I think is a much better use of the space. The majority of the changes, however, are under the hood. As you may recall, I redeveloped the site using Django a while ago. Since then I've spent a lot more time with Django and know a lot more about it, so I completely redeveloped the site (using the newforms-admin branch and was able to make a lot of improvements to the code, and basically leave it better positioned to integrate more features in the future. Among other things, I plan on migrating this blog to a Django-based solution and integrating it into the dy/dx tech website to some extent. I've been working heavily with Django for the past several months, and I just keep liking it more and more. It makes every part of my job so much more enjoyable and, in a lot of cases, faster. Be on the lookout for another project going live in the next couple weeks: this one will be Django-based and will be very public, and, I predict, very popular.
June 2nd, 2008
Currently I've got two projects hosted on WebFaction servers. So far, I really like them. As managed hosts go, they're probably the best I've worked with, and they certainly make life very easy when building Django powered sites.
Today I got an email from one of the clients whose project is hosted on WebFaction saying that their site is down. So I checked it out, and while I was able to access it, it was extremely slow, to the point where a less forgiving browser/LAN setup might cause it to time out. So I fired off a support ticket to WebFaction, and within a couple minutes, not only was the site back up to speed, but I was provided with a very good explanation for why my server was having problems.
Apparently there was an explosion at one of WebFaction's data centers this weekend. It took out power to the data center, but fortunately no one was hurt and none of the servers were damaged. Obviously, there have been some interruptions in service for the servers in that data center (which includes both of my WebFaction projects), but they've already gotten a significant number of the servers back online (though only one of mine).
Amazingly, this is actually the second time I've had a server taken out by an explosion at a data center. The first time was with a hosted Microsoft Exchange server with a hosting company in London.
It really sucks having sites down, especially critical ones (fortunately only one of the projects I have hosted with them is critical, and it's the one that's back up already), but as reasons for downtime go, you have to admit that an explosion is a pretty good one.
More posts >