Django Remote Include and RSS to HTML Template Tags

I wrote some pretty cool template tags last night for Django.  One that you can use to include the content of a remote URL into a template, and another that pulls down an RSS/Atom feed and writes it out as CSS classed HTML.

Both of them can run in simple or cached mode.  In cached mode, they cache the results for a specified amount of time in seconds.

Here are the tags:

remote_include.py

rss2html.py

The rss2html.py tag requires the Universal Feed Parser in the same directory as rss2html.py or at least on the python path.

Here is a template example for using both tags:

<html>
  <head>
    <titleTemplate Tag Testing</title>
  </head>
  <body>
    <h1>Remote Include - No caching</h1>
    {% sri http://carsongee.com/ %}
    <h1>Remote Include - Caching for One Hour</h1>
    {% cri http://carsongee.com/ 3600 %}
    <h1>RSS 2 HTML - No Caching</h1>
    {% rss2html http://carsongee.com/rss.xml %}
    <h1>RSS 2 HTML - Caching for One Hour</h1>
    {% rss2htmlcache http://carsongee.com/rss.xml 3600 %}
    <h1>RSS 2 HTML - Caching or Not - Specify Number of Entries</h1>
    {# Grab first 3 entries #}
    {% rss2html http://carsongee.com/rss.xml 3 %}
    {% rss2htmlcache http://carsongee.com/rss.xml 3600 3 %}
  </body>
</html>

That is pretty much all there is to it. Let me know in the comments if you have any issues.

 
 
 
 

Formunculous 2.1.1 Available

Just finished a bugfix release for Formunculous. So feel free to go grab it. Or install it straight from the command line with:

easy_install formunculous

now that it is in the cheese shop.

 

Here is the small list of changes:

  • Now fully compatible with both Django 1.1 and 1.2 (any bugfix release)
  • Word fixes (replacing "Application" with "Form" - legacy problem)
  • Minor HTML and CSS fixes
  • Completed form sorting and paging fixes
 
 
 
 
 
 
 
 

Remote Backup of Files, Subversion, and MySQL Using Rsync and Ssh

TuxRecently my VPS provider was doing some power maintenance and recommended backing up data.  I realized I hadn't made a backup of that system in very long time, and hadn't worked up a backup strategy.  This caused me to whip up a backup solution using my two favorite things; ssh and rsync.

In the past I had used tar and scp to do remote backups, but this painfully slow, and I don't have a requirement to do moment in time backups, so the amazing efficiency of rsync.  The only trick was that this server has subversion and MySQL databases, and doing a straight copy of the data for these apps is extremely dangerous.  So with a couple remote ssh commands run from the backup machine I ended up with a slick, simple, fast, and reliable backup script:

#!/bin/bash

# Individually backup relevant etc configurations using rsync
# with the archive and compressions flags set
rsync -az -e "ssh -i path/to/ssh/key" backup_user@example.org:/etc/apache2 /data/backup/etc/
.
.
rsync -az -e "ssh -i path/to/ssh/key" backup_user@example.org:/etc/ssl /data/backup/etc/

# Use remote commands to trigger app specific backups for MySQL and subversion

# Run safe backup of all MySQL databases to a location that gets rsynced later
ssh -i path/to/ssh/key backup_user@example.org "mysqldump -u root -pPassword --all-databases > /opt/backup/mysql-current.sql"

# Run safe backup of subversion using svnadmin dump to a directory that gets rsynced
ssh -i path/to/ssh/key backup_user@example.org "svnadmin dump --quiet /opt/repos/svn > /opt/backup/svn.current.dump"

# Sync /opt.  Backup everything.  This will grab the remote MySQL and subversion backups
# we just made.
rsync -az -e "ssh -i path/to/ssh/key" backup_user@cexample.org:/opt/ /data/backup/opt/

That is it. I get a safe backup of my databases and svn plus all of my file data ~8 GiB total, and after the initial backup it all happens in less than 5 minutes.

Attach it all to crontab like:

0 * * * * /usr/local/bin/backup.py

and you get an hourly synchronized copy of the remote server.

 

 
 
 
 

Formunculous Website Launched

Formunculous Website screenshot

I have been somewhat feverishly working on the design and implementation of a project Website for Formunculous, and I am really quite happy with the results.  I've really been focusing on a visual design and illustration skills as of late, and I thought I would be fun to show off some of those results using a Website I've wanted to create for quite some time.  Let me know what you think.

 
 
 
 

Formunculous 2.1 Release

New Statistics FeatureThis is a new feature release that adds several graphical statistics, CSV export, and form history views among many others. This release focused on increasing usability and user interface design.

Features and Bugs Fixes

New features:

  • Graphical statistics for showing responses over time.
  • Pie charts for showing percentage choices for drop down type fields.
  • Improved notification e-mail with direct links to related areas of the app.
  • Interface improvements on form index page--tab with forms available for review.
  • New review tab shows the number of complete and incomplete forms for each form.
  • Incomplete forms are now shown on the reviewing view along with the completion percentage.
  • There are now print links on the completion page and review page for forms.
  • Link to download all of the files associated with a form definition as a single zip file.
  • There is a link to export all form submission data as a single CSV.
  • Restyle of form building view to make it more compact.
  • The accordion expansion handle for form building is now available in a larger area.
  • In the builder index, inactive forms are now greyed out.
  • Each column in the builder index is now sortable.
  • Input errors for the end user have an improved look and feel
  • If you have an authenticated multi-use form, the user can now view each form that they have previously filled out.

Bug Fixes:

  • Sorting on the review index has been improved to include fields with the special "None" value.
  • Searching forms in the review index now properly cases and trims the search terms.
  • The preview form no longer shows the submit/save buttons.
  • Copying a form definition now properly performs a deep copy of dropdown selections and sub-forms.
  • Copying a form definition now properly copies the site status and list of reviewers.
  • Notification for non-authenticated forms no longer sends multiple e-mail notifications if the user refreshes the page.
  • Verification of whether the requested form is a parent or child is now working properly.
 
 
 
 

The Chalkboard Fridge Project

Since last weekend, Deena and I have been completing and working on the oft talked about, long ago planned, project of the The Chalkboard Fridge (dun dun dun).  We have had a kegerator for a long time and have always wanted to do something more with it than just drink delicious beer served out of the tap.  Mostly things like doodle on it, install a second tap, and keep track of the temperatures and pressures for making sure each pull brings another perfect pour.  In order to solve two of those problems, chalkboard paint.  About $20.00 in primer paint and rollers, and a little elbow grease is all it took.  We primarily followed the guide we found at The Kitchn, and here are the results:

The Beginning - Front The Beginning - Side Sanding Primer Coat - Front Primer Coat - Side First coat of chalkboard paint Chalkboard paint - the second coatening "Curing" the paint Erasing the new chalkboardComplete

 
 
 
 

Django Admin Integration

I love python and Django is probably the best Web application framework I have ever worked with, but it isn't without its issues.  It has an absolutely great built-in, auto-generated admin interface for directly modifying database objects.  It is incredibly convenient and takes care of most common Web application administration needs for the vast majority of applications.  That being said, if it doesn't work for your application it can be painful to shim extended admin interfaces into it.  

For example it doesn't really fit with Formunculous or File Manager than it is pretty much the exact opposite of convenient.  I have wrestled with integrating other application's admin interfaces into the Django admin with out much success.  The look and feel is easy thanks to template extensions, but just creating a simple link to your extended admin views is just not there, and there isn't really a recommended way to do it.

 
 
 
 

Dell Updates

A quick update about my Dell Latitude saga.  I called customer service today at 7:00 a.m. and had a pleasurable and productive, albeit lengthy, exchange with their representatives.  I have managed an exchange for the ill-fated Latitude XT, and the process is everything that it should be.  They are sending a replacement laptop, and when I receive it, I'll just have to send the broken one back.  Hopefully they will ship it overnight, but that is doubtful, and I still haven't received any confirmation e-mails or phone calls that the exchange is going to actually happen.  I am cautiously optimistic.

Quick Update (2/10/2010):

I have heard back from Dell, and everything appears to going well so far.  I will say that I was dismayed that the standard laptop exchange takes 10-12 days to process.  They have assured me however that my exchange is a high priority and will be shipped overnight when it is ready.

Another Quick Update (2/18/2010):

 So, I received the replacement laptop as of yesterday, and everything works.  Well, pretty much everything.  The battery it came with was near dead, and while I did receive two CD-ROM attachments, one doesn't fit the CD-ROM, and the other, which does fit the CD-ROM uses e-SATA instead of USB, which the laptop doesn't have available.  So 8 days, and overnight shipping means it wasn't too bad of a wait for exchange, and just as I was about to call Dell about the not quite right bits I received a call from them.  They were OK with me swapping batteries, and tech support should take care of getting the right CD-ROM bit to me.  All in all, it took about three weeks to get everything straightened out, which was a tremendously long time, but on the plus side everytime I interacted with Dell's customer support staff, it was delightful (minus the call about the original shipment of the first laptop).

 
 
 
 

Love Hate Relationship with Dell

Dell has been the primary provider of commodity hardware in my current and last job.  At the NITC they were our primary provider of commodity servers, but the more exotic kit such as SAN, switching, and routing gear were left to field leaders in those areas.  I was extremely happy with their servers, we had great support, good pricing, and rock solid reliability.  At the KU School of Engineering Dell is the primary provider of all our IT systems including desktops, laptops, some switches, and all of our storage gear.  Again, I have been satisfied for the most part, though the prices and features for some of their re-branded storage kit has been painful.  The point of all that is that when it came to purchasing a replacement tablet for my girlfriend choosing a Dell Latitude XT series tablet seemed like a no brainer.  Wow, was that a mistake.  The entire experience has just been a nightmare.

 
 
Syndicate content