Sunday, October 23, 2011

Weekend Project: Image Thumbnailer - Day 1

Day 1

8:12 pm - overview

I'm about to dive into the process of creating an image thumbnailer, I'm giving myself 2 hours. (update from the retrospectoscope: 2 hours would have been realistic with experience, this turned out to be more of a 5 hour undertaking in short bursts over the weekend).
So far I've setup pyramid:
sudo easy_install virtualenv
virtualenv --no-site-packages pyramid
cd pyramid
. bin/activate

8:16 pm - generating the project

I've decided to name my project 'imageuploadr'
paster create -t pyramid_starter imageuploadr
cd imageuploadr
python develop

8:26 pm - simple template customization

Had a short emergency was distracted for about 5 minutes
I decided to test tinkering with the template first, templates are sensibly located in the 'templates' folder.
edited imageuploadr/templates/ I added the string 'hey you *****'
Pyramid comes with it's own server I launched it with the following command
paster serve development.ini
And was able to view the app in my browser at:
My customization showed up:

8:40 - tinkering with views

The file is important, it allows us to control stuff.

Making a views folder because I like it better than a monolithic file.

I renamed the file to, created a views folder and then moved into the new folder. The new structure is shown below:

I also had to edit the imageuploadr/ file

9:18 - just getting used to working with requests

Next I've done some rearranging of the code imageuploadr/views/, the goal is get familiar with requests. My changes will make my view 'listen' out for a firstname and lastname.

I also adjusted the template to use the firstname and lastname keys (this is pretty primitive as the app now breaks if I don't pass a firstname and lastname to the request.
Now my imageuploadr/templates/ now has the following snippet:
hey you ***** ${lastname} ${firstname}
The following url: now results in:

9:35 - documenting

Mostly just documenting what I've done so far.

9:42 - form processing

So now I want to see a form being processed.
Adding the following code to the template:
I purposely used a post as I'm going to need that for my file upload later.
<form method="post" action="./">
         <label>Lastname<input type="text" name="lastname" /><label>
         <label>Firstname<input type="text" name="firstname" /><label>
         <input type="submit" />
Now I can add my firstname and lastname via a form.

 Unfortunately household chores distracted me so I'll need to get back to this later.
Continued in Part II >>

No comments:

Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos