Another simple but useful Django trick

Say you need the full URL of the current page you're displaying that you need to use on the template of that page, for example, to add links to Facebook, Delicious, etc., and you don't want to have additional JavaScript that you didn't write on your pages. (Why yes, I'm a control freak, shush. :P) Also say that you don't want to use the sites framework to hack it together. The permalink decorator won't work, either, because that just gives you the relative link.

Thankfully, there's a new request object that's been added to 1.0 that will do it.

To use it, include the bolded bit in your views.py file, as part of each view where you want to have the variable available:

return render_to_response('dir/template.html', {'object': obj, 'link': request.build_absolute_uri()}, RequestContext(request))

Then you can use the link variable on the template where you need the URL:

<a href="http://www.facebook.com/sharer.php?u={{ link|urlencode }}&t={{ title|urlencode }}">

Happy Earth Day!

Of course, I think every day should be Earth Day. If you make just one change today to change your impact on the world around you, that'd be a wonderful thing. *vbg*

Try something simple, one step at a time:

  • Use reusable bags every time you go to the store–any store: grocery, book, craft, etc. Tip: after you've used your bags to haul things into the house, immediately take them back out to your car or put them back in something that's always with you so you'll have them the next time you shop and don't fall back on the excuse that you forgot to bring them with you. In no time at all, it'll be second nature to grab the bags before you enter a store. :)
  • Take your reusable cup with you and refill it rather than using disposable cups.
  • Bring your own name tag with you to conferences and meetings.
  • Replace as many lightbulbs in your house with CFLs as you can.
  • Pack your or your kids' (if you have 'em) lunches in a lunch box or reusable containers rather than paper bags.
  • Recycle everything you can, even the annoying hard plastic packaging that so many things are wrapped in.
  • Compost non-meat-based waste. (Seriously, if I can do it, anybody can. *vbg*)

What's your favorite tip to give others a start on making the world around them a better place?

You can make a difference! (Really, it's not that hard to do. *vbg*)

Links roundup

Links to reviews of Brushback by Jamie Scofield:

[livejournal.com profile] elisa_rolle:

What I found really interesting is that the author didn't choose the visual "effect" to build the attraction between Evan and Roman, he/she chose to build an attraction based on little things, like the timber of voices, common interests… chemistry.

Review is here.

Three Dollar Bill Reviews:

If you like complex characters and well plotted mysteries then you can't go wrong with Brushback. I thought it was terrific and can't recommend it highly enough.

Review is here (five out of five stars).

Rainbow Reviews: review is here (three and a half out of five stars).

• Rainbow Awards winner: 2nd place (tie): Best Mystery/Thriller Novel and 3rd place (tie): Best Overall Gay Novel

Dear idiot package maintainer:

Changing damned near every USE flag on a minor (!?!?!) release (0.8.34 to 0.8.34-r1) for a package WITHOUT DOING A DAMNED GOOD JOB DOCUMENTING THE CHANGES is a monumentally stupid idea and all you're going to do is annoy the crap out of people who use the package.

Is it a good idea to add support in gentoo for (nearly) all of the nginx modules, rather than the few that were previously being supported? Yes, it's fabulous. Thank you very much for working on this.

Is it a good idea to move all the module choice settings to USE_EXPAND? I have no friggin' clue, because there is NO DOCUMENTATION on how to, y'know, use USE_EXPAND. (I'm damned good at finding information, no matter where it's squirreled away. And yes, I RTFM. It's not there.) As it stands now, all you did was a) break my nginx installation (I made one minor change to a config file so I could restrict access to my new awstats installation and spent four hours tracking down why it wouldn't let me restart the nginx server), and b) changed my package.use entry for nginx from this:

www-servers/nginx -* fastcgi imap pcre ssl zlib

to this:

www-servers/nginx -* http ssl nginx_modules_http_access nginx_modules_http_auth_basic nginx_modules_http_autoindex nginx_modules_http_empty_gif nginx_modules_http_fastcgi nginx_modules_http_geo nginx_modules_http_gzip nginx_modules_http_gzip_static nginx_modules_http_limit_req nginx_modules_http_memcached nginx_modules_http_referer nginx_modules_http_rewrite

Wow. That's helpful. (Read: not terribly, actually.)

No love,
Me.


In the absence of any actual useful documentation, I had to try a bunch of different options to get nginx to do what I wanted it to do again. There was some indication (on pages about other packages) that USE_EXPAND was to be put in /etc/make.conf, as well as the package's variable (NGINX_MODULES_HTTP, in this case). So something like this should've worked, right?

NGINX_MODULES_HTTP="access auth_basic autoindex empty_gif fastcgi geo gzip gzip_static limit_req memcached referer rewrite"
USE_EXPAND="NGINX_MODULES_HTTP"

But nope, that was a no-go. I think it actually makes more sense to be able to set the modules variable in /etc/portage/package.use, seeing as that's the currently accepted file location for detailed USE flag settings, but what do I know? I'm just a user. /sarcasm

Neither of those options (or any of the others I tried) worked. As stated above, I ended up changing the nginx line in my package.use and re-emerging nginx with the new USE flags. Hopefully this tip will help out anyone else who runs into this problem and will save many wasted hours.

Amen!

Visit msnbc.com for breaking news, world news, and news about the economy

Please contact your senator and the White House.