Archive for the 'Greg’s Comments on the Internet' Category

How to Display Realtime Traffic Analytics

posted on September 2nd, 2009 by pyroman in Greg's Comments on the Internet

I left that out of the post because I didn’t change it from what Apache was installed with on my debian box. It looks like this.

#

# The following directives define some format nicknames for use with

# a CustomLog directive (see below).

# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i

#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%r\" %>s %b" common

LogFormat "%{Referer}i -> %U" referer

LogFormat "%{User-agent}i" agent

Format reference: http://httpd.apache.org/docs/1.3/mod/mod_log_config.html#for…

Read more comments by Greg Allard

Conditions on Count or Sum in MySQL

posted on August 28th, 2009 by Greg Allard in Greg's Comments on the Internet

yeah that looks like it should work

Read more comments by Greg Allard

Xapian-haystack – A Xapian backend for Django Haystack

posted on August 11th, 2009 by pyroman in Greg's Comments on the Internet

I was using haystack with whoosh and running into the same problem. I was waiting for some updates on that, but I think I’ll check this out first. Thanks for sharing the code.

Read more comments by Greg Allard

A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin

posted on August 10th, 2009 by Greg Allard in Greg's Comments on the Internet

That would work. If you are using a signal (pre_delete or post_delete), you might need to send it from the new function since you wouldn’t want to call the real delete.

I’ve been doing object.deleted = 1 object.save() and not calling or overriding delete(). That way I still have the option to do the real delete in case I need it. You could probably make a real_delete() function to do that if needed though.

Read more comments by Greg Allard

Python Projects in Users’ Home Directories with wsgi

posted on July 22nd, 2009 by Greg Allard in Greg's Comments on the Internet

I like the AddHandler approach more than what I was trying in this post. It is better since AddHandler will work in an .htaccess file. Which means this doesn’t require a new public_python folder and doesn’t require /p/ to be added to the url.

Before arriving at the solution in my post I tried using an .htaccess file and the directives I tried weren’t supported in .htaccess. I didn’t read the part about AddHandler so I missed that.

Something with either WSGIDaemonProcess or WSGIProcessGroup from the code in the blog post is making those applications work in daemon mode. It seems like any wsgi file that is touched will result in the code being reloaded for that project.

Read more comments by Greg Allard

A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin

posted on July 22nd, 2009 by Greg Allard in Greg's Comments on the Internet

I tested this out with a simple many to many example and I am not getting the soft deleted objects returned. With objects = SoftDeleteManager the many to many queries will be using get_query_set() which won’t return the soft deleted records. I might need to see an example of how you are getting the deleted results to be able to figure out what is going on. I tried it with some_object.related_things.all() and the returned set won’t have deleted related_things.

Read more comments by Greg Allard

Python Projects in Users’ Home Directories with wsgi

posted on July 9th, 2009 by Greg Allard in Greg's Comments on the Internet

I tried it without the LocationMatch directives and it works with just having AliasMatch in there for the static locations.

I didn’t expect that WSGIDaemonProcess wouldn’t expand the python_project_name. I was doing that so that each project would have a different process so touching one wsgi file wouldn’t effect another project. It seemed like it was working like that.

If you can figure out a better way of doing this that would be awesome.

Read more comments by Greg Allard

Python Projects in Users’ Home Directories with wsgi

posted on July 8th, 2009 by Greg Allard in Greg's Comments on the Internet

Thanks for taking at look at this. I’ll test it without SetHandler None when I get a chance. It is probably something I was keeping around from when I was using mod_python. I’m guessing I need to keep LocationMatch in there so that the request doesn’t go to the wsgi file though, right?

Read more comments by Greg Allard

Python Projects in Users’ Home Directories with wsgi

posted on July 8th, 2009 by pyroman in Greg's Comments on the Internet

I tried doing it that way first, but the wsgi directives aren’t allowed in an .htaccess file. It would have been much better to have a user place a few lines in their .htaccess file for python projects, but I didn’t find a way of doing that.

Read more comments by Greg Allard

A Django Model Manager for Soft Deleting Records and How to Customize the Django Admin

posted on July 2nd, 2009 by Greg Allard in Greg's Comments on the Internet

You can do this.
from somewhere import SoftDeleteManager

class NewManager(SoftDeleteManager):
”’new stuff”’

and in the model
objects = NewManager()

Read more comments by Greg Allard