Pylons File Upload

January 29, 2011
Tags: ,

This code snippet should clear up the confusing documentation when it comes to uploading an optional picture :

import os
from pylons import config
import shutil
class MyController(BaseController):
    def picture(self, registration=False):
        if ’send_picture’ in request.params:
            if (‘picture’ in request.params) and hasattr(request.params[‘picture’], ‘filename’):
                [...]

Comments Off

jQuery – Safe ‘onReady’ code

January 7, 2011

Just a quickie that combines the $(fn) method of calling a function when the DOM is ready, with an anonymous function that ensures that $ refers to jQuery :

(function($) {
      $(function () {
        // your code to fire when the DOM is ready
      });
    })(jQuery);

Comments Off