Oct. 14th, 2009

elfs: (Default)

I needed some rails-like environment settings using Django.  This is the quick and easy way to get that done.   First, after building your “settings.py” file, create an environment under your project root named “env“.   Move your settings.py file to this directory, rename it “development.py"

Now, in your root directory, open up a new file named “settings.py” and put this in:

import os
import os.path

PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))

local_import = "env/development.py"
if os.getenv("DJANGO_ENV") == 'TEST':
    local_import = "env/test.py"
elif os.getenv("DJANGO_ENV") == 'PRODUCTION':
    local_import = "env/production.py"

import_file = open(os.path.join(PROJECT_ROOT, local_import))
exec(import_file)

Bingo!  Now you have different versions of settings.py depending upon whether or not you’re starting the server in TEST, PRODUCTION, or the default, “development”.  Create production.py and test.py as needed.  You can start the server with:

DJANGO_ENV=TEST ./manage.py runserver

And it will load the correct environment.  Using a shell script to run a test server and then a test harness might not be the most elegant thing in the world, but at least it’s Un*x, and it makes development less stressy.

Sweet!

This entry was automatically cross-posted from Elf's technical journal, ElfSternberg.com
elfs: (Default)
I've been trying to be less shrill recently, and avoiding the news, and normally I wouldn't link to an article from the Kossacks, but this had me giggling hysterically for more than a few minutes...

Inappropriately.

(I should add a warning: the second half of the video might be highly disturbing to folks especially sensitive to animal cruelty.)

elfs: (Default)
I must be in a foody mood. I've been cooking a lot recently. Today's menu: Seared scallops, pasta pilaf w/lemon & chives, and asparagus w/honey & lemon.
  • 1 small onion
  • 1 cup orzo or other small pasta
  • 1 cup chicken or vegetable broth
  • 1/2 cup white wine
  • 1/4 tsp thyme
  • 2 tbs fresh chives
  • juice of 1 lemon
  • 1.5 pounds sea scallops
  • 1 lb baby asparagus
  • 2 tbs honey
  • Olive oil
  • Canola oil
  • Salt & pepper
If the scallops are frozen, start defrosting them in a colander by running cool water over them.

Heat 1 tbs olive oil in a non-stick saucepan. While it's warming up, chop the onion. Saute' the onion for 3-5 minutes until glassy, then add the pasta (we were out of orzo, but had plenty of kid-friendly star and alphabet pasta the kids stopped eating ages ago, still good), the broth, the wine and thyme. Lower to a simmer and let cook for 15 minutes. You'll know when it's done when the pasta has absorbed all the liquid.

While the pasta is cooking, chop the chives, snap the bottoms off the asparagus and discard, and juice the lemon. Mix half the lemon juice, the honey, and four cups of water and put it all into a large pot. Tie the asparagus with string (or, heck, a rubber band) and stand them up in the pot. Cover, put on high heat, and steam for 4-7 minutes. You can tell when they're done when they turn a handsome dark green.

Bring an iron skillet to medium-high to high temperatures; put in just enough canola oil to cover. (I use canola instead of olive because canola burns at a higher temperature). Toss the sea scallops with salt and pepper, then put into the hot skillet and sear 3 minutes on a side.

When the pasta is done, add in the other half of the lemon juice and chives, set aside and keep warm.

If you're so inclined, toss a tablespoon of butter down the stalk of the asparagus. Either way, remove asparagus from the water and unstring.

If you time it right, everything will be done within two minutes of each other, so serve. Total cooking time, about 25 minutes. Good with crusty bread and a cold drink such as white wine or beer.

Adult content )

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 4th, 2026 03:39 pm
Powered by Dreamwidth Studios