Monday
15
Mar 2004

Special forces hand signals

(5:51 pm) Tags: [General]

Warning, big image!!!!
Whereas, ’special forces hand signals’ was the number one search on dotnot.org from google, and whereas the link on my prior post has disappeared, I have decided to serve the image directly from here: special forces hand signals

Popularity: 27%

Comments: (0)
Saturday
6
Mar 2004

integrate cheetah and mod_python

(6:19 pm) Tags: [How do I...]

…and I do not want to precompile my templates. This one was pretty simple, as there is one recipe on the Cheetah Wiki about it. We start there and just modify it a bit. Here goes. First, we add the following somewhere in our apache config (I added it to my .htaccess):

Apache configuration for mod_python and cheetah
AddHandler mod_python | .tmpl
PythonHandler cheetah

That was easy, now we write the code for cheetah.py:

Cheetah integration code
01: import string
02: from mod_python import apache
03: from mod_python import Session
04: from Cheetah import Template
05:  
06: def handler(req):
07:  
08:     session = Session.Session(req)
09:     req.session = session
10:     req.content_type = “text/html”
11:     base_path = req.get_options()[’base-path’]
12:     template_name = string.replace(req.uri, base_path, “”)
13:     template_name = findfile(template_name)
14:     template = Template.Template(file=template_name, searchList=[req])
15:     content = template.respond()    
16:     req.send_http_header()
17:     req.write(content)
18:  
19:     return apache.OK

Pretty simple really.

How much easier can it be? Now you create the template (hello.tmpl):

Cheetah template code
#set $place = “World”
Hello $place

Now, when you hit http://localhost/example/hello.tmpl, you will see “Hello World”.

Popularity: 13%

Comments: (1)

Cheetah and mod_python

(6:06 pm) Tags: [Software]

I have now settled on using Cheetah along with mod_python and Apache 2 for my new new web framework, and I find myself only missing 2 things from the PHP world:

  1. php.net’s awesome documentation
  2. overriding variables in {include} directives in Smarty
.
I have posted a question to the cheetah discussion list, to see how I would go about telling my includes that variables have changed. We’ll see what I can come up with. It is the only clean way that I can think of to make sure that child includes know nothing of their parent (the way Alex taught me to code my PHP) :)

Popularity: 10%

Comments: (1)

find a file in python’s path

(5:59 pm) Tags: [How do I...]

I am building a simple web framework in Python, and I need everything to be inheritable and extinsible. This includes content. So, I am doing the brain dead thing and using Python’s sys.path to search for content that may not have been overridden in the current context. The code was hacked up from a version I found here, in the first comment. I will try to find the link and post it later. This version is greatly simplified.

find a file in Python’s sys.path
import os, sys
 
def findfile(path):
    ”"”Find the file named path in the sys.path.
    Returns the full path name if found, None if not found”"”
    for dirname in sys.path:
        possible = os.path.join(dirname, path)
        if os.path.isfile(possible):
            return possible
    return None

Popularity: 13%

Comments: (0)
Thursday
4
Mar 2004

We found a house

(4:29 pm) Tags: [Life]

Found a house in Rough and Ready, CA (just west of Nevada City/Grass Valley), made an offer, and the offer has been accepted. Now we aren’t as homeless as we used to be ;)

The house is 2600 square feet on 5.3 acres, with a 2400 square foot shop. The shop is a bit small, but I’ll learn to make do :) The house is 4 bedrooms and 2.5 baths, with a 3 car garage. We are far enough ‘in the country’ to have a well and septic system. It is 10 months old (which is jolly good). I will try and post pictures soon.

When this is all said and done, I will also have a recommendation for a realtor in the Nevada County, CA area. He has been great so far, we just need to finish so that I can share the story.

Popularity: 32%

Comments: Comments Off