Re: GeoDjango / GIS Garbage Collection Error

2008-09-25 Thread Fredrik Lundh
Justin Bronn wrote: > [W]hen __del__() is invoked in response to a module being deleted > (e.g., when execution of the program is done), other globals > referenced by the __del__() method may already have been deleted. > > Thus, the solution is to not to not import GEOS globals from a >

Re: Sorting list of objets in Python/Django

2008-09-21 Thread Fredrik Lundh
Nianbig wrote: > I have a people-list like this: class a: > ... def __init__(self, name, number): > ... self.name = name > ... self.number = number > ... b = [] b.append( a('Smith', 1) ) b.append( a('Dave', 456) ) b.append( a('Guran', 9432) )

Re: Dynamic images

2008-09-17 Thread Fredrik Lundh
Jarek Zgoda wrote: > You can just return the content (bytes) in HttpResponse with > appropriate content-type header. First argument to HttpResponse > constructor is the content. if you're using PIL to create the image, you can (usually) save the image to the response object, e.g.

Re: URL RegEx problem for oembed

2008-07-25 Thread Fredrik Lundh
Marty Alchin wrote: > Also, though, I have to ask why you're using such a complicated URL > pattern in the first place? For some applications, I can understand > accepting a full URL, but your pattern is expecting something very > specific, which means you're not looking to accept just any

Re: Memory Usage/Optimization Question

2008-04-05 Thread Fredrik Lundh
Garrett Garcia wrote: > I recently got my first django project set up on webfaction and am > feeling the constraint of their memory usage limits. > For example: > > I have a view that returns a list of objects: > > def get_meet_results(request, meet_id): > meet =

Re: Django book error

2008-04-04 Thread Fredrik Lundh
Poz wrote: > Problem is the libjpeg link no longer exists I've also installed > MacPort and it errored when installing the PIL > > Does anyone know another way to install the PIL?? any mac expert here that can check if the pythonmac.org packages work? see:

Re: got error when use code of djangobook chapter 7 for searching

2008-01-19 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > all code came from here: > http://djangobook.com/en/1.0/chapter07/ > in my view: > def search(request): > query = request.GET.get('q', '') > if query: > qset = ( > Q(title__icontains=query) | > Q(forum__title__icontains=query) |

Re: Django Performance

2008-01-15 Thread Fredrik Lundh
shabda wrote: >> use django in a shared hosting environment or I need to buy a >> Dedicated server? > While many people run Django in shared hosting, IMHO, that leads to > much more trouble than it is worth. But you surely do not need a > dedicated server for running django. I use Webfaction,

Re: dynamic choices in a ChoiceField

2008-01-13 Thread Fredrik Lundh
Alex Koshelev wrote: > When you explicitly write list in choices it evaluates at module > import type. To avoid this write function and pass it as 'choices' > parameter > > def get_choices(): > [(d.id,d.name) for d in Deck.objects.all()] (adding a return statement might be a good idea /F)

Re: Restart Django site?

2008-01-10 Thread Fredrik Lundh
Michael Hipp wrote: > How do I restart my Django site (uses FastCGI and shared hosting via > .htaccess)? > > The docs say 'touch mysite.fcgi' but that does not seem to work. Tried > touching all the py files as well as .htaccess. > > I can see the python process still running in memory. If I

Re: django

2008-01-10 Thread Fredrik Lundh
Patricia Ramirez wrote: > you solve your problem with django, i have the same error message, and i > don't not why happend > > File "", line 1 > django-admin.py startproject mysite >^ > SyntaxError: invalid syntax looks like you typed the

Re: How is this page being loaded?

2008-01-09 Thread Fredrik Lundh
Darthmahon wrote: > I've been looking through the source code for djangoproject.com which > is really useful and has helped me a lot, but I have a question > regarding the code. > > Does anyone know how the url www.djangoproject.com/community know > which template it needs to load? > > I've

Re: Django... False promises?

2008-01-03 Thread Fredrik Lundh
LRP wrote: > Why didn't The Book steer me right to begin with? possibly because Django runs on tons of platforms, and those platforms tend to change even faster than Django itself. any attempt to provide complete installation details for all possible configuration variants on all supported

Re: easy way of rerouting print messages

2007-01-25 Thread Fredrik Lundh
Benedict Verheyen wrote: > In other apps, i use the logging module with a RotatingFileHandler, so > that i don't have to worry about log files getting to big. > Is there a way to use that package too? import logging ? --~--~-~--~~~---~--~~ You received

Re: 'function' object has no attribute 'rindex'

2006-12-27 Thread Fredrik Lundh
Don Arbow wrote: > Well, I meant bug in the sense of the book. I noticed that this same > question was asked about a > month ago. I'm not sure if the book emphasizes which version of Django to > use for the tutorials. http://www.djangobook.com/en/beta/chapter02/ >>> import django >>>

Re: serving multiple hosts from a single django instance ?

2006-12-26 Thread Fredrik Lundh
Fredrik Lundh wrote: that almost worked, but causes some rather interesting problems with things like CommonMiddleware's URL rewriting, etc. I came up with this little hack instead: I've posted the patch and the middleware I'm using here: http://effbot.org/zone/django-multihost.htm

Re: startswith a range

2006-12-25 Thread Fredrik Lundh
Jeremy Dunck wrote: NOT_GIVEN="(*piuhuI&*uyobJH!ikuoi1p9e;mks c0p[p" def reduce_(f,s,i=NOT_GIVEN): it=iter(s) if i == NOT_GIVEN: hmm. if you post code like that often enough, we may have to revoke your python coder's license ;-) ::: for the archives, here's the "right" way to do

Re: serving multiple hosts from a single django instance ?

2006-12-22 Thread Fredrik Lundh
Fredrik Lundh wrote: ah, that could work. maybe the process_request handler could just modify the path attribute, in place ? that almost worked, but causes some rather interesting problems with things like CommonMiddleware's URL rewriting, etc. I came up with this little hack instead

Re: serving multiple hosts from a single django instance ?

2006-12-21 Thread Fredrik Lundh
James Bennett wrote: can this be done? Sure. We do that all the time, with multiple sites living in a single Apache instance. Generally it's just a matter of setting up a couple different virtual hosts, and using the sites framework to ensure that content for one site doesn't show up on

serving multiple hosts from a single django instance ?

2006-12-21 Thread Fredrik Lundh
I have an application where it would be rather convenient if I could serve multiple host names from a single django *instance*. the sites share the same database and most of the views, so I basically only need to plug in a separate urlconf for each host. can this be done?

Re: CSS Basics

2006-12-21 Thread Fredrik Lundh
Ivan Sagalaev wrote: are you trying to say that Django's static server doesn't filter the URL before adding it to the document root ? Sure it doesn't. so what's the # Clean up given path to only allow serving files below document_root. part doing, then ?

Re: CSS Basics

2006-12-21 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Static servers are usually designed where the URL maps to part of the file system. You asked earlier why static files (such as css and image files) should not be stored alongside the scripts. This is because a clever hacker could guess where you have stored your

Re: >*< Free PC to PC access >*< Remote Access software >*

2006-12-21 Thread Fredrik Lundh
Shabana wrote: http://remote-softwares.50webs.com/ there's no way to get google groups to simply just nuke anything that mentions 50webs.com ? --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: Bug? -- Scripting to Store Images Throws Exception but Still Successfully Stores Image

2006-12-20 Thread Fredrik Lundh
Paul Childs wrote: I have a lot of images for the initial load and want to use a script to get them into the database. > When I try to store the image in my Photo model (see the below) I get an error. C:\Python24\lib\site-packages\django\db\models\base.py in _save_FIELD_file(self, field,

Re: Is there an easy to "humanize" a list?

2006-12-20 Thread Fredrik Lundh
Brian Beck wrote: from django.utils.text import get_text_list doesn't match the OP's specification for all lists, though: >>> get_text_list(["one", "two", "three"], 'and') 'one, two and three' but I guess you could always do if len(seq) >= 2: text = get_text_list(seq, ", and")

Re: Is there an easy to "humanize" a list?

2006-12-20 Thread Fredrik Lundh
Waylan Limberg wrote: Not that we need another way but this would work as well, and it doesn't need special cases for one and two item lists but does insert the "and" (unlike most of the solutions offered): def humanize_list(list): return ", and".join(map(str, ", ".join(map(str,

Re: Is there an easy to "humanize" a list?

2006-12-20 Thread Fredrik Lundh
James Aylett wrote: Is there an easy way to output that as: "foo, bar, and twinky" If you want to do it in python, use reduce: -- # l is the list, r is the humanised result r = reduce(lambda x, y: str(x) + "," + str(y), l)

Re: Estimate memory/cpu of django?

2006-12-15 Thread Fredrik Lundh
mamcxyz wrote: > Exist any info about estimates values for memory and cpu for django? depends on what you're doing. my main django server uses around 12 megabyte memory and no noticeable CPU, during normal operations. I'm sure the Curse folks [1] use a lot more resources ;-) in other

Re: Installation on Python25

2006-12-14 Thread Fredrik Lundh
Jeremy Dunck wrote: > Here's a 3rd: you can cut and paste from a dos box. They change it > on each version of windows, but I think on 2k, you click the icon for > the dos window (or perhaps it's right-click the title bar), and select > Mark. Drag your cursor around to highlight a segment, and

Re: caching when multiple domains point to the same server

2006-12-13 Thread Fredrik Lundh
Fredrik Lundh wrote: > how do I troubleshoot this? by hitting myself in the head with a suitable object, obviously. (when using CACHE_MIDDLEWARE_ANONYMOUS_ONLY, make sure you're logged out when testing cache behaviour...) --~--~-~--~~~---~--~~ You recei

caching when multiple domains point to the same server

2006-12-13 Thread Fredrik Lundh
hi, I've just set up a django server which is currently available through multiple domain names, and I just noticed that caching only works for one of the domains. what have I missed? how do I troubleshoot this? (I'm using 0.95 on the deployment server, btw)

Re: High Load

2006-12-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > We are running lighttpd with fastcgi in prefork mode. We tried using > threaded but django spits out an error about a weakly-referenced > object, related to sessions I believe, no longer existing. it's not related to this, by any chance:

Re: Singleton model instance

2006-12-04 Thread Fredrik Lundh
Phil Powell wrote: > Perhaps I've not explained myself properly. Here's an example: > > I have a "Homepage" which has fields such as "Page Title", > "Introduction Text", "Footer Text" etc. I want to be able to edit > these fields just like I'd edit a standard model instance, but because >

Re: Singleton model instance

2006-12-04 Thread Fredrik Lundh
Phil Powell wrote: > I want to have a series of pages, with certain areas of content which > are editable. I don't want to use flatpages, as I'd like the editable > content to be broken down into chunks, rather than one big lump of > content. > > Is there a way to easily set a model to have

Re: Why not Django

2006-12-01 Thread Fredrik Lundh
Victor Ng wrote: >> that might be true for the US deficit, but for more normal money >> amounts, that's not really true at all. > > Basic currency conversion for Euro would require 5 decimal places of > precision with no rounding involved: > http://europa.eu.int/ISPO/y2keuro/docs/ep22-en.pdf

Re: Why not Django

2006-11-30 Thread Fredrik Lundh
Victor Ng wrote: > If you're dealing with money at all - you absolutely cannot use float, > you *must* use fixed decimal types or you risk getting into all kinds > of really terrible rounding errors. that might be true for the US deficit, but for more normal money amounts, that's not really

Re: offtopic: delete *.pyc from subversion

2006-11-29 Thread Fredrik Lundh
Kenneth Gonsalves wrote: >> when I do "svn diff" the pyc-files are still listed. >> guess I have to delete that files from the repository first. right? > > svn remove will delete the files on the next commit adding things to global-ignores does *not* affect files that are already checked in.

Re: offtopic: delete *.pyc from subversion

2006-11-29 Thread Fredrik Lundh
Rob Hudson wrote: > Yes, I guess I should have said "And tell subversion to ignore them." if you read the original message again, you'll notice that the OP had already done that. --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Re: What is __init__.py for?

2006-11-19 Thread Fredrik Lundh
ringemup wrote: > I've noticed all these __init__.py files are generated when you create > a new app in django, and I can't find any documentation on them. What > are they for? What does one do with them? it tells Python that the directory is a package directory. if you have

Re: Urgent upgraded to fedora core 6 python doesnt work if you guys know any pointer pls help out

2006-11-18 Thread Fredrik Lundh
James Bennett wrote: > On 11/19/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote: >> Make sure that your psycopg2 build matches with your postgres's libs. > > Also, he could probably get more effective help by asking on the > web.py mailing list, since he's using that and not Django... From:

Re: encode special character in rendering template into XML

2006-11-18 Thread Fredrik Lundh
can.xiang wrote: > Fredrik, thanks for your idea and snippet. If I have to put xml > generating code in views I would follow you. it works just fine for (X)HTML fragments too, of course. (...and is especially useful of you're creating the context variables on the fly, using

Re: encode special character in rendering template into XML

2006-11-17 Thread Fredrik Lundh
can.xiang wrote: > Thanks for your suggestion. I was thinking about generate XML in views > directly. > > But the XML file I want is just simple one like HTML(they are also > small) and it's all about presentation, thus it doesn't make sense to > put them into views. > > Any other way to do

Re: Upgraded, now I'm hosed

2006-11-13 Thread Fredrik Lundh
"[EMAIL PROTECTED]" wrote: > I posted this before, but don't see it... hope I'm not double-posting. > > Last night I upgraded to 4066 and now I'm getting lots of errors like: > invalid syntax (models.py, line 1) > Request Method: GET > Request URL: >

Re: Django Hosting

2006-10-20 Thread Fredrik Lundh
Ian Holsman wrote: > what's anonymous about it ? relying on a twisting little maze of DNS records to figure out who you might be doing business with? I guess we have different standards... --~--~-~--~~~---~--~~ You received this message because you are

Re: Django Hosting

2006-10-20 Thread Fredrik Lundh
"Guest007" wrote: > http://www.djangodomain.com/ ah, the warm and fuzzy feeling of a faceless web provider hiding behind an anonymous web contact form, and with a "terms of service" page copied word by word from other similar sites...

Re: putenv() argument 2 must be string, not list

2006-09-14 Thread Fredrik Lundh
"Atayal" <[EMAIL PROTECTED]> wrote: > When I open my browser for http://192.168.0.22/photoalbum/helloworld/ > > I run into the following error message: > TypeError: putenv() argument 2 must be string, not list > === > > I am on Debian,