Re: login_required decorator conflicts with admin documentation view

2007-01-05 Thread James Bennett


On 1/6/07, James Bennett <[EMAIL PROTECTED]> wrote:

What's needed to actually make this work is for user_passes_test to
copy over __module__ and __name__ from the decorated function to its
internal _checklogin function, in addition to __doc__.


Also, it's worth pointing out that this has actually been tried, but
breaks backward compatibility; __name__ was a read-only attribute up
until Python 2.4.

--
"May the forces of evil become confused on the way to your house."
 -- George Carlin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: login_required decorator conflicts with admin documentation view

2007-01-05 Thread James Bennett


On 1/6/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:

On 06-Jan-07, at 11:32 AM, chasfs wrote:
> Any suggestions other than removing the login_required decorator and
> doing the work in each view?
use user_passes_test - this has an option for adding the return url


Unfortunately, that won't help with documentation; from the point of
view of Python -- and remember that documentation is obtained by
standard Python introspection -- the decorated function has been
clobbered. The '_checklogin' function he's seeing is a function
defined internally in user_passes_test (since login_required is just
user_passes_test with an authentication check, you see this no matter
which decorator you use).

In theory, the documentation _could_ work because user_passes_test is
smart enough to copy the original view's docstring and attach it to
the decorated function, but the problem here is that the links to view
documentation auto-generated in the admin concatenate the view's
__module__ and __name__ attributes to get a view name, but both of
those get clobbered by the decorator; __module__ becomes
'django.contrib.auth.decorators' (since that's the module the
decorator lives in) and __name__ becomes '_checklogin' (since that's
the name of the internal function returned from inside the decorator).
Concatenating those gets the non-existent function name
'django.contrib.auth.decorators._checklogin', which is why he gets a
404 in the admin docs when trying to view it.

What's needed to actually make this work is for user_passes_test to
copy over __module__ and __name__ from the decorated function to its
internal _checklogin function, in addition to __doc__.

--
"May the forces of evil become confused on the way to your house."
 -- George Carlin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: login_required decorator conflicts with admin documentation view

2007-01-05 Thread Kenneth Gonsalves



On 06-Jan-07, at 11:32 AM, chasfs wrote:


Any suggestions other than removing the login_required decorator and
doing the work in each view?


use user_passes_test - this has an option for adding the return url

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Kenneth Gonsalves



On 06-Jan-07, at 11:22 AM, David Abrahams wrote:



i have light traffic - but messing with those helped immensely


Rather than me fishing in the dark, can you suggest some changes?
Like, "increase the min" or something?


i have:
StartServers 5
Minspareservers 5
maxspareservers 10
maxclients 20
maxrequests per child 5

the last two you can play with

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Weird apache problem

2007-01-05 Thread Chris Brand


I got apache with mod_python up and running ok.

Then I used manage.py reset on one of my apps.

Since then, I can't see that app in the Admin page. It was showing up fine 
before. It also shows up fine if I use the development server.

I've restarted apache, my browser and even mysqld, all to no avail.

I don't even know how I can go about diagnosing what's going on.

Help!

Chris

Do you know about the dangers of DRM? Find out at 
http://www.defectivebydesign.org/what_is_drm

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



login_required decorator conflicts with admin documentation view

2007-01-05 Thread chasfs


I'm having a problem using the auto generated admin documentation for
views, when the view has an @login_required decorator.  Instead of
linking to the doc for the view, the link is to:
http://localhost:8000/admin/doc/views/django.contrib.admin.views.decorators._checklogin/
which is not found.

Any suggestions other than removing the login_required decorator and
doing the work in each view?

Thanks!
-chasfs


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread David Abrahams


Kenneth Gonsalves <[EMAIL PROTECTED]> writes:


On 05-Jan-07, at 9:11 PM, David Abrahams wrote:


Next most likely is # of child processes.  Try fiddling with Min and
MaxSpareServers.
 http://httpd.apache.org/docs/2.0/mod/prefork.html


According to the docs that should only be necessary if I have very
heavy traffic.  I don't; far from it.  So I'm reluctant to mess with
those.


i have light traffic - but messing with those helped immensely


Rather than me fishing in the dark, can you suggest some changes?
Like, "increase the min" or something?

Thanks.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Converting a Django site to flat HTML

2007-01-05 Thread goon


Rob Hudson wrote:

wget -E --load-cookies /path/to/firefox/profiles/cookies.txt -r -k -l
-r = recurse ...'


I missed this with pycurl & have yet to find example that supports it
:(  Then I scanned the curl FAQ and found 3.15 [0]


3.15 Can I do recursive fetches with curl?
http://curl.mirrors.cyberservers.net/docs/faq.html#3.15


This means to use pycurl you need a list of urls. This is difficult as
you need to parse the returned page. I would have thought curl could
support this. Obviously not. One obvious way is to use pycurl by
pointing it to a base url, then for each returned page (assuming html)
parse with HTMLParser [1] build a list for each url and extract the
pages that way.

Not what you asked. Want a quick hack solution do what 'Rob Hudson'
suggests & use wget (which you probably did anyway) OR otherwise try an
old favourite of mine and use websucker. [2] The reason I looked at
pycurl was the obvious django, pycurl integration (ie: a django app
that mirrored sites).


Reference

[0] Curl FAQ, 'Can I do recursive fetches with curl?, NO'
http://curl.mirrors.cyberservers.net/docs/faq.html#3.15
[Accessed Saturday, 6 January, 2007]

[1] Python HTMLParser module, ''Parses text files in format of HTML &
XHTML'
http://docs.python.org/lib/module-HTMLParser.html
[Accessed Saturday, 6 January, 2007]

[2] python websucker, 'creates "mirror copy of a remote site"'
http://svn.python.org/view/python/trunk/Tools/webchecker/
[Accessed Saturday, 6 January, 2007]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: appname in admin

2007-01-05 Thread Terji7



Andy Dustman wrote:


You need to provide your own replacement for some admin templates,
specifically admin/base_site.html and maybe admin/base.html, depending
on what you want do do, and put them in one of your TEMPLATE_DIRS.


For i18n purposes it would be neat if you could do it in the model
definition e.g. for a class called Blog_entry you could in its Meta
class have a classname variable or similar, so the class name that
shows up in he admin may be non-ascii. That would lessen the need to
deal with templates...just my opinion.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: model referencing itself

2007-01-05 Thread Aidas Bendoraitis


I think, you will also need related_name parameter for your relating fields.

Regards,
Aidas Bendoraitis aka Archatas



On 1/5/07, Jorge Gajon <[EMAIL PROTECTED]> wrote:


Hi Aljosa,

On 1/4/07, Aljosa Mohorovic <[EMAIL PROTECTED]> wrote:
>
> i'm trying to create a model which referencing itself and for this
> code i get this error:
> "name 'Chapter' is not defined"
>
> how do i do this or something similar?
>
> code:
> >>>
> from django.db import models
>
> class Chapter(models.Model):
> name = models.CharField(maxlength=200)
> content = models.TextField()
> prev = models.OneToOneField(Chapter)
> next = models.OneToOneField(Chapter)
> <<<
>

Try with:
 prev = models.OneToOneField('self')
 next = models.OneToOneField('self')


Regards

>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-To-Many relationships, select_related()

2007-01-05 Thread Aidas Bendoraitis


I can think of a couple of ways:

1. Using intermediate table for Many-to-many relationship:
class UserPermission(models.Model):
   user = models.ForeignKey(User)
   permission = models.ForeignKey(Permission)

user_permissions = UserPermission.objects.select_related().all()

2. Writing some custom SQL query to select the same thing -- the
intermediate table, joining users and permissions, and then ordering
by users.

Regards,
Aidas Bendoraitis aka Archatas


On 1/3/07, Trey <[EMAIL PROTECTED]> wrote:


Is there a problem in django's many-to-many relationship mapper when it
comes to selecting the related fields? In this simple example I have a
user with permissions and they are related via an intermediary table.
"select_related()" only brings back the User object and each access of
a Permission object results in a query.

Is there a way to avoid making N queries to the database where N is the
number of users that I have?

Example Model and ORM Call:

class App(models.Model):
name = models.CharField(maxlength=32)

class Permission(models.Model):
name = models.CharField(maxlength=32)
description = models.CharField(maxlength=255)
app = models.ForeignKey(App)

class User(models.Model):
username = models.CharField(maxlength=32)
password = models.CharField(maxlength=48)
first_name = models.CharField(maxlength=50)
last_name = models.CharField(maxlength=50)
permissions = models.ManyToManyField('Permission')

user = User.objects.select_related().all()


Thanks, Trey


>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django on REDHAT ES

2007-01-05 Thread [EMAIL PROTECTED]


they are actually all installed. and yet this error still comes up.
rebooting apache didn't help ~ it's all very odd. perhaps some path
issue?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: including a template in itself

2007-01-05 Thread Aidas Bendoraitis


This is (or at least, was) impossible in Django template system,
because the includes are performed before block (i.e. {% for ... %} or
{% if ... %}) manipulation. When you do as you wrote, Django executes
infinite recursion. Therefore, it crashes.

Anyway, you still have several solutions to that problem:
1. You can write some large limited number of recursing markup into
the same template.
2. You can write a template tag, which would include another template
according custom parameters.
3. You can write a recursive function, parsing the templates in the
view, and execute it in the views level.

Regards,
Aidas Bendoraitis aka Archatas



On 12/30/06, Rob Slotboom <[EMAIL PROTECTED]> wrote:


I've a template which will be included. Within the template I want to
include it again if needed.

child_list.html

{% if categorie %}
   {{ categorie.title }}
   {% if categorie.child_set.all %}
  
  {% for categorie in categorie.child_set.all %}
 {% include "child_list.html" %}
  {% endfor %}
  
   {% endif %}
{% endif %}

When I do this Django crashes


>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: edit_inline disables slug prepopulation?

2007-01-05 Thread Aidas Bendoraitis


As far as I remember, It's not normally available for the fields of
the inline-edited models. However, you can still add some custom
JavaScript to the admin template to implement that functionality.

Good luck!
Aidas Bendoraitis aka Archatas



On 12/27/06, ringemup <[EMAIL PROTECTED]> wrote:


Hello --

I'm having a problem with a model that I have set to edit inline with a
related model.  Basically, the slugs are not auto-populating from the
fields they're supposed to use.  Here's the model in question:

class Player(models.Model):
name = models.CharField(maxlength=50, core=True)
slug = models.SlugField(prepopulate_from=['name'], unique=True)
team = models.ForeignKey(Team, edit_inline=models.TABULAR,
num_in_admin=10, num_extra_on_change=10, null=True, blank=True)
...
(snipped)

Is prepopulation simply not available in inline editing, or did I make
a mistake somewhere?

Thanks!


>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: PostgreSQL schema support

2007-01-05 Thread Kenneth Gonsalves



On 06-Jan-07, at 12:56 AM, Christoph Haas wrote:

I'd like to hear comments. Or is PostgreSQL an uncommon DBMS to use  
with Django? (btw, is there a reason to prefer psycopg over  
psycopg2?) I can of course restrain myself to the "public" schema  
but my application would benefit from different schemas.


postgres is the rdbms of choice for django. psycopg1 and 2 are  
incompatible - and there is so much legacy code in psycopg1 that many  
users are unwilling to switch. I agree with you with regard to  
schemas - for example a multicompany financial accounting application  
could use schemas to create the tables for each company.


--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Kenneth Gonsalves



On 05-Jan-07, at 10:26 PM, David Abrahams wrote:



 NameVirtualHost: *:80

so is that name-based?


yes - and since you have only one IP, the question is moot

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: appname in admin

2007-01-05 Thread Andy Dustman


On Jan 5, 9:08 pm, "Aljosa Mohorovic" <[EMAIL PROTECTED]>
wrote:

i can't find info on how to change appname in admin interface.
example:
if i have "my_cool_app" app in project and it has admin interface
enabled it will display something like "My_cool_app" in
administration, can i make it display "My cool app description"?


You need to provide your own replacement for some admin templates,
specifically admin/base_site.html and maybe admin/base.html, depending
on what you want do do, and put them in one of your TEMPLATE_DIRS.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Kenneth Gonsalves



On 05-Jan-07, at 9:11 PM, David Abrahams wrote:


Next most likely is # of child processes.  Try fiddling with Min and
MaxSpareServers.
 http://httpd.apache.org/docs/2.0/mod/prefork.html


According to the docs that should only be necessary if I have very
heavy traffic.  I don't; far from it.  So I'm reluctant to mess with
those.


i have light traffic - but messing with those helped immensely

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem setting up a separate media server

2007-01-05 Thread stoKes




On Dec 13 2006, 7:46 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote:

Good point - done.

http://code.djangoproject.com/wiki/CookBookUsingExternalMedia

-joehttp://www.rhonabwy.com/wp/

On 12/13/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote:



> On 12/13/06, Joseph Heck <[EMAIL PROTECTED]> wrote:
> > We're using

> > blah blah  blah
> ...
> > And then in the settings.py under TEMPLATE_CONTEXT_PROCESSORS, we added:
> >"myproject.context_processors.common",

> > There may well be a much better way to accomplish this all, but that
> worked
> > out nicely for us.

> We're doing exactly the same thing.  This isn't a provided dj context
> processor due to the slippery slope of including all settings in
> context.  It's been raised many times.  Adding media_url should
> probably be a cookbook entry...


what about defining images in your stylesheets?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



appname in admin

2007-01-05 Thread Aljosa Mohorovic


i can't find info on how to change appname in admin interface.
example:
if i have "my_cool_app" app in project and it has admin interface
enabled it will display something like "My_cool_app" in
administration, can i make it display "My cool app description"?

Aljosa

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: PostgreSQL schema support

2007-01-05 Thread Russell Keith-Magee


On 1/6/07, Christoph Haas <[EMAIL PROTECTED]> wrote:


The problem has been raised in
- http://code.djangoproject.com/ticket/1051



Did anyone else find a workaround? Is it meanwhile possible to use at least
a models.py without using "inspectdb"? My experiments
with 'schemaname.tablename' just lead me
to "public"."schemaname.tablename" which is obviously not what I want.

I'd like to hear comments. Or is PostgreSQL an uncommon DBMS to use with
Django? (btw, is there a reason to prefer psycopg over psycopg2?) I can of
course restrain myself to the "public" schema but my application would
benefit from different schemas.


Postgres is the database that is used by most of the core developers,
AFAIK (it's certainly my DB of choice, and Jacob has blogged Postgres
as his preference in the past). The only reason to prefer psycopg over
psycopg2 is historical - the API for psycopg2 wasn't finalized until
quite recently, so we didn't recommend using it. However, the psycopg
backend has a few problems with unicode, so I suspect the official
line may soon switch to 'use v2' (probably before Django goes v1.0).

Regarding schema - I can't think of any fundamental objection to
including them, other than whatever method is used must degrade
gracefully to the other DB backends. The reason that ticket #1051
hasn't received any attention is because it simply isn't a priority
for the core developers. Personally, I've never had a Django-related
application where namespacing became anything close to a problem
requiring a solution.

However, if someone were to do a good triage job (see the docs for
what this means - and for the record, this would constitute a 'big
change'), and the required changes degraded gracefully to the other
backends, and there was documentation, and there were tests exercising
the functinoality, I don't see any reason that support for Postgres
schemas couldn't be included.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can I do this. Forms and Manipulators.

2007-01-05 Thread Russell Keith-Magee


On 1/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Is this a valid idea for the solution or are there other ways to do
this?



Search the Django-user archives - there was a thread about a month ago
titled 'Multiple Models on one Form' where I gave a couple of
solutions to this kind of problem.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopg installation error: C compiler cannot create executables

2007-01-05 Thread Alasdair


Oh - one more thing: James Bennett posted over at TextDrive saying he'd
installed psycopg via DarwinPorts, but I've been trying to do that over
the last couple of days and it stalls while trying to fetch PostgreSQL
8.1.3 (which it wants as a precondition for installing py-psycopg).

I don't know if this helps - there might be a way grab it without
DarwinPorts trying to install PostgreSQL but I don't know of a way.
Please excuse my ignorance in these matters...

- Alasdair


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: psycopg installation error: C compiler cannot create executables

2007-01-05 Thread Alasdair


If Joseph's suggestion doesn't work, you may want to look at your Xcode
installation. I had the same output as you when trying to install
psycopg until I updated my Xcode install (following advice on a forum
thread in French which I've since lost). You'll have to create a
developer account at the Apple webpage
(http://developer.apple.com/tools/) if you haven't already done so, but
that's a snap. Seems some earlier versions of Xcode have a problem with
specifying multiple chip architectures for gcc. I'm not sure if this is
your problem - looking at your config.log might help (you might see
something specifying both powerpc and i386 arch right before the fail).


Also, if you get past this, let us know how things go, as I'm still
trying to configure psycopg. I no longer get PostgreSQL header
problems, but I'm getting a "can't build without PostgreSQL libraries"
problem. The configure exits after looking for PQconnectStart:

checking for mxDateTime.h... yes
checking for main in -lcrypt... no
checking for main in -lcrypto... yes
checking for PQconnectStart in -lpq... no
configure: error: can't build without PostgreSQL libraries

after I configure using:
./configure --with-postgres-libraries=/usr/local/pgsql/lib
--with-postgres-includes=/usr/local/pgsql/include
--with-mxdatetime-includes=[path/to]/mx/DateTime/mxDateTime

I don't know if I should try messing around with libpq, or if I need to
recompile both PostgreSQL and psycopg without SSL support, or something
like that.

I hope everything works out - keep us posted.

- Alasdair


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Question about request.has_key()

2007-01-05 Thread John M


I am still learning about HTTP requests, etc, and am looking for an
good explination of how django handles the whole coorelation between a
form button's values / names and the has_key() function, I think they
are related.

For example, I'd like to mimic the multiple buttons on the admin
interface for Save / Save Continue / Delete functions, and in looking
at the code, they are checking for request.has_key("...").

The docs for the request.has_key() is a simple sentence that someone of
my (low) level of HTTP knowledge can't really seem to put together.

Any help on what / how they work would be awesome!

Thanks


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with site domain in Admin interface

2007-01-05 Thread Tool69


+1 , I don't think a beginner can have the idea to search the id index
in his datase first.
The first thing we do naturaly is to look at our code, and there we
find nothing wrong...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



newforms: help on an individual field?

2007-01-05 Thread Chris Green


Often times, I want to attach documentation or examples in the middle
of a form, just to make it clear to a user what types of data would be
acceptable.

Does this use-case automatically push me from using {{form}} and into
rendering everything about the form myself or do people think this is
generic enough that the automatic parts of {{form}} should handle it?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Handling bad URLs

2007-01-05 Thread Adrian Holovaty


On 1/5/07, James Bennett <[EMAIL PROTECTED]> wrote:

I wonder if maybe it would help if ObjectDoesNotExist were to become a
subclass of Http404, so that an uncaught ObjectDoesNotExist exception
would just become a 404...


No can do -- that would couple the database layer to HTTP, which
wouldn't be a good thing.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting data that will be written

2007-01-05 Thread leanmeandonothingmachine


turns out i was modifying the values in a post_init and thats why I
thought I wasn't getting the right thing.

On Jan 5, 3:33 pm, "leanmeandonothingmachine"
<[EMAIL PROTECTED]> wrote:

tx for the reply sry about the double post

On Jan 5, 3:31 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:

> On 1/5/07, leanmeandonothingmachine <[EMAIL PROTECTED]> wrote:

> > I have a model where I'm using the save(self) method, but I can't
> > figure out how to get the data that will be writen without writing it
> > to the db first. I need to modify a value that's being writen.Just acccess 
the various fields of the mode object; at the point
> save() is being called, the copy of the object in memory has already
> had its field values changed, regardless of whether the changes have
> been written into the database.

> --
> "May the forces of evil become confused on the way to your house."
>   -- George Carlin



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting data that will be written

2007-01-05 Thread leanmeandonothingmachine


tx for the reply sry about the double post

On Jan 5, 3:31 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:

On 1/5/07, leanmeandonothingmachine <[EMAIL PROTECTED]> wrote:

> I have a model where I'm using the save(self) method, but I can't
> figure out how to get the data that will be writen without writing it
> to the db first. I need to modify a value that's being writen.Just acccess 
the various fields of the mode object; at the point
save() is being called, the copy of the object in memory has already
had its field values changed, regardless of whether the changes have
been written into the database.

--
"May the forces of evil become confused on the way to your house."
  -- George Carlin



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting the new data value

2007-01-05 Thread leanmeandonothingmachine


tx for the reply sry about the double post

On Jan 5, 3:07 pm, David Zhou <[EMAIL PROTECTED]> wrote:

On Jan 5, 2007, at 2:04 PM, leanmeandonothingmachine wrote:

> How do you get values that will be written to the db in a models
> save(self) method before you save the changes to the db? I tried
> self.field but that gives what the current db value is? I need change
> the data that is being written, but I'd rather not have to do multiple
> writes to the db.self. returns the value about to be written for me?

Are you sure it's retrieving the value from the db?

---
David Zhou
[EMAIL PROTECTED]



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting data that will be written

2007-01-05 Thread James Bennett


On 1/5/07, leanmeandonothingmachine <[EMAIL PROTECTED]> wrote:

I have a model where I'm using the save(self) method, but I can't
figure out how to get the data that will be writen without writing it
to the db first. I need to modify a value that's being writen.


Just acccess the various fields of the mode object; at the point
save() is being called, the copy of the object in memory has already
had its field values changed, regardless of whether the changes have
been written into the database.

--
"May the forces of evil become confused on the way to your house."
 -- George Carlin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database session leak with postgres or is it open transactions

2007-01-05 Thread marxy


Ok, it turns out that when you kick of a thread and use the db a new
database session is created. You do need to explicitly do a
connection.close() at the end of your thread's run method or the
session leaks.

I got rid of all the setDaemon() calls, no good or bad effects.

Cheers,

Peter


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting the new data value

2007-01-05 Thread David Zhou



On Jan 5, 2007, at 2:04 PM, leanmeandonothingmachine wrote:


How do you get values that will be written to the db in a models
save(self) method before you save the changes to the db? I tried
self.field but that gives what the current db value is? I need change
the data that is being written, but I'd rather not have to do multiple
writes to the db.


self. returns the value about to be written for me?

Are you sure it's retrieving the value from the db?

---
David Zhou
[EMAIL PROTECTED]




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Getting data that will be written

2007-01-05 Thread leanmeandonothingmachine


I have a model where I'm using the save(self) method, but I can't
figure out how to get the data that will be writen without writing it
to the db first. I need to modify a value that's being writen.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom template(s) for sitemaps?

2007-01-05 Thread [EMAIL PROTECTED]


Just wondering, has anyone tried a custom template for sitemaps?
I'm thinking (a) I'd like to manually add things that I can't seem to
generate for the sitemap
and (b) I'd like to use the sitemap framework to build an html sitemap
for the site.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Getting the new data value

2007-01-05 Thread leanmeandonothingmachine


How do you get values that will be written to the db in a models
save(self) method before you save the changes to the db? I tried
self.field but that gives what the current db value is? I need change
the data that is being written, but I'd rather not have to do multiple
writes to the db.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: where does the old manipulator go?

2007-01-05 Thread Waylan Limberg


On 1/5/07, Ramdas S <[EMAIL PROTECTED]> wrote:

have considered all your suggestions and have tried something like this. But
it still fails. I have numerous errors, I guess. I have marked in yellow,
potential issues.

Many Thanks if you can help me fix it



The logic in your view is a little off. If there is no POST data, you
want to initialize the form with no data so try this:



def register(request):

if request.user.is_authenticated():
# Do Not register users already there
return render_to_response('quizapp/register.html',
{'has_account': True})


   if request.method = 'POST':
   form = RegistrationForm(request.POST)
   if form.is_valid():
# your code here...
# ...
return
render_to_response('quizapp/register.html', {'created': True})

   else:
 form =  RegistrationForm()

   return render_to_response('quizapp/register.html', {'form': form })

Note that the last line is not inside the else and gets called either
if there was no POST data (as an empty form) or if the POST data is
NOT valid (so the form is redisplayed with error messages and
pre-populated with the errant data)
--

Waylan Limberg
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with site domain in Admin interface

2007-01-05 Thread James Bennett


On 1/5/07, Tool69 <[EMAIL PROTECTED]> wrote:

Thank you Baxter,
you avoid me a big waste of time and effort. I was studing my Django
code, and couldn't find the answer.
The problem was solved in changing kib2.webfactionnal.com to 1, as you
said.


Cross-posting this to django-developers because I'm about to make a
suggestion...

We should probably add notes to the official docs on the sites
framework explaining that the default 'example.com' Site object is
important, and that the correct way to get the domain name and other
aspects right is to edit that object, not to delete it and create a
new one; I've seen way too many people get tripped up with weird
issues on account of deleting the Site object with id 1.

If anyone else thinks this would be a good idea, I'll see about
working up a documentation patch.

--
"May the forces of evil become confused on the way to your house."
 -- George Carlin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



PostgreSQL schema support

2007-01-05 Thread Christoph Haas


Dear list...

I'm currently starting a larger project and want to use Django for it. 
First order of business was creating the necessary database schema with 
pgadmin3 (a PostgreSQL GUI). Next thing after setting my settings.py right 
was to run "django-admin inspectdb" to get my already existing database 
schema into a models.py. Unfortunately the models.py was mostly empty. I 
figured out it's due to my use of PostgreSQL schemas. Django just didn't 
find my tables.


/*
Where other DBMS like MySQL just have databases and tables you can use an 
additional layer to seperate different applications or parts of your 
application into schemas. Where in MySQL you have database->table you have 
database->schema->table in PostgreSQL. You query them through e.g.


SELECT * from schemaname.tablename;

You may think of those schemas just as different namespaces. The default 
namespace is 'public' and automatically prepended through a search path 
variable.

*/

The problem has been raised in
- http://code.djangoproject.com/ticket/1051
- http://code.djangoproject.com/ticket/1208
already.

I'm running Django 0.95 on Debian.

Did anyone else find a workaround? Is it meanwhile possible to use at least 
a models.py without using "inspectdb"? My experiments 
with 'schemaname.tablename' just lead me 
to "public"."schemaname.tablename" which is obviously not what I want.


I'd like to hear comments. Or is PostgreSQL an uncommon DBMS to use with 
Django? (btw, is there a reason to prefer psycopg over psycopg2?) I can of 
course restrain myself to the "public" schema but my application would 
benefit from different schemas.


Kindly
Christoph

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with site domain in Admin interface

2007-01-05 Thread [EMAIL PROTECTED]


I'm sure Tool69 and I aren't the only two who've been tripped up by
this.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: RFC newforms usage

2007-01-05 Thread Adrian Holovaty


On 1/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

i started reimplementing my old manipulators code using newforms. Can u
guys give me some feedback on my usage of it?

What i wrote seems to me a lot of code for a 3 field form (even though
part of the bloat is due to date formatting)

Here's the code:
http://dpaste.com/hold/4382/


Also, delete_academic_year() should check request.method == 'POST'. As
it stands, anybody who visits that page via GET will cause deletion.
Deletion should only happen via POST.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: RFC newforms usage

2007-01-05 Thread Adrian Holovaty


On 1/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

i started reimplementing my old manipulators code using newforms. Can u
guys give me some feedback on my usage of it?

What i wrote seems to me a lot of code for a 3 field form (even though
part of the bloat is due to date formatting)

Here's the code:
http://dpaste.com/hold/4382/


* Take advantage of AcademicYearForm.clean_data rather than parsing
the date fields yourself.

* There's no reason to do request.POST.copy().

* At the end of add_academic_year(), if it's successful, you should
redirect rather than returning the output of change_academic_year().
Always redirect after doing a request.POST, so that people who use the
back button don't retrigger the POST. This is not strictly a Django
thing; it's a Web development best practice.

In short:

def add_academic_year(request, info_msg=""):
   if request.method == "POST":
   form = AcademicYearForm(request.POST)
   if form.is_valid():
   ay = AcademicYear(**form.clean_data)
   ay.save()
   return HttpResponseRedirect('/url/to/change/page/')
   else:
   context = {'form': form, 'error_msg': "Please correct the
error(s) below"}
   else:
   context = {'form': AcademicYearForm()}
   return render_to_response('academic_year.html', context)

You can also just use form_for_model, like so:

def add_academic_year(request, info_msg=""):
   AcademicYearForm = form_for_model(AcademicYear)
   if request.method == "POST":
   form = AcademicYearForm(request.POST)
   if form.is_valid():
   ay = form.create()
   return HttpResponseRedirect('/url/to/change/page/')
   else:
   context = {'form': form, 'error_msg': "Please correct the
error(s) below"}
   else:
   context = {'form': AcademicYearForm()}
   return render_to_response('academic_year.html', context)

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: where does the old manipulator go?

2007-01-05 Thread Ramdas S

have considered all your suggestions and have tried something like this. But
it still fails. I have numerous errors, I guess. I have marked in yellow,
potential issues.

Many Thanks if you can help me fix it

Thanks for reading...

Here is my forms.py
---

from django.newforms import *
from django.contrib.auth.models import User

class RegistrationForm(Form):
   username = RegexField(r'^[a-zA-Z0-9_]{3,30}$',
 max_length = 30)
   email=  EmailField()
   password1 =CharField(min_length=6, max_length =20, widget=
PasswordInput)
   password2 = CharField(min_length=6, max_length =20, widget=
PasswordInput)

   def clean(self):
   if self.clean_data.get('password1') and
self.clean_data.get('password2')
and self.clean_data['password1'] != self.clean_data['password2']:
   raise ValidationError(u'Please make sure your passwords match.')
   return self.clean_data
   def isValidUsername(self, field_data, all_data):
   try:
   User.objects.get (username=field_data)
  except User.DoesNotExist:
   return
   raise ValidationError('The username "%s" is already taken.' %
field_data)

   def save(self, clean_data):
   u = User.objects.create_user(clean_data['username'],
clean_data['email'],
clean_data['password1'])
   u.is_active = False
   u.save()
   return u


Here is my views.py


import datetime, random, sha
from django.shortcuts import render_to_response, get_object_or_404
from django.core.mail import send_mail
from django.newforms import *
from django.contrib.auth.views import login as auth_login
from quiz.quizapp.models import UserProfile
from quiz.quizapp.forms import RegistrationForm



def register(request):

   if request.user.is_authenticated():
   # Do Not register users already there
   return render_to_response('quizapp/register.html', {'has_account':
True})

   form = RegistrationForm(request.POST)
   if request.POST:
   if form.is_valid():# Save the user
   data = form.clean_data

   # Build the activation key for their account
   salt = sha.new(str(random.random())).hexdigest()[:5]
   activation_key = sha.new(salt+new_user.username).hexdigest()
   key_expires = datetime.datetime.today() + datetime.timedelta(2)

   # Create and save their profile
   new_profile = UserProfile(user=new_user,
 activation_key=activation_key,
 key_expires=key_expires)
   new_profile.save()



   email_body = _('Hi, %s, thank you for registering for
To confirm this registration click the link below within 48 hours \n\n \
http://quiz/userprofile/confirm/%s')
% (
   new_user.username,  new_profile.activation_key)

   # Send an email with the confirmation link
   email_subject = _('Confirmation of your new account)

   send_mail(email_subject,
 email_body,
 [new_user.email])

   return render_to_response('quizapp/register.html', {'created':
True})


   form = form.clean_data # I am not able to get the Formwarapper
   return render_to_response('quizapp/register.html', {'form': form })

def confirm(request, activation_key):
   if request.user.is_authenticated():
   return render_to_response('confirm.html', {'has_account': True})
   user_profile = get_object_or_404(UserProfile,
activation_key=activation_key)
   if user_profile.key_expires < datetime.datetime.today():
   return render_to_response('confirm.html', {'expired': True})
   user_account = user_profile.user
   user_account.is_active = True
   user_account.save()
   return render_to_response('confirm.html', {'success': True})

  

Ramdas S


On 1/5/07, Vadim Macagon <[EMAIL PROTECTED]> wrote:



Honza Kr l wrote:
> Hi Ramdas,
> the "Right Way (tm)" how to solve this using newforms is:
>
> 1) subclass Field to create a field representing (and validating)
username:
>
> class UserField( forms.Field ):
>  def clean( self, value ):
>do what you must to verify username, throw validation error if you
> are not satisfied with the data

I'd just like to point out that subclassing isn't the only way to add
custom validation to a field, you can also implement the clean_FIELDNAME
method on your form, or override the forms clean(), this is how I've
done it:

class RegistrationForm(forms.Form):
   username = forms.RegexField(r'^[a-zA-Z0-9_]{3,30}$',
   max_length = 30)
   <- rest of the fields here ->

   def clean_username(self):
 <- additional validation code here ->
 <- raise forms.ValidationError if data is invalid ->


-+ enlight +-

>



--~--~-~--~~~-

Re: Why so slow?

2007-01-05 Thread David Abrahams


"Joseph Heck" <[EMAIL PROTECTED]> writes:


Everyone's looking at the web serving mechanisms, so let me ask a
relatively obvious question - are you doing anything complex
database-wise on the page that's being so slow?


Most pages shouldn't require any DB lookups.  I don't see PostgreSQL
soaking cycles, either.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread David Abrahams


"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:


On Jan 5, 2:54 am, David Abrahams <[EMAIL PROTECTED]> wrote:

I am developing a Django-based site, and it *really* seems to be
slow... sometimes.  It's running in an Apache virtual server on the



Any insight you might have is appreciated.


Are you sure it's not a client issue?


No I'm not.


I had a problem with ffox 1.5 and 2.0 which i fixed disabling ffox IPV6
support and other stuff (maxrequests and so on). The site was crawling,
but it wasn't Django's fault.


Did your problem cause intermittent slowness, or was it consistent?
Mine's rare but bad-when-it-happens.


Try testing with IE if you happen to have it handy.


I do.  I just brought it up and the first few accesses were slowish,
but not awful.  Had terrible response with Safari yesterday.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread David Abrahams


"Jeremy Dunck" <[EMAIL PROTECTED]> writes:


On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote:
..

> Except that KeepAlive ties up processes waiting for further requests
> from a client, which may never come (and certainly won't if you run
> media separately as recommended.

So you're saying that basically the docs are wrong (not questioning
you; just trying to understand better)?


The docs aren't wrong, per se-- KeepAlive generally does result in a
performance improvement.  


I didn't mean that.  I meant the part about the default settings being
good unless traffic is very high.


KeepAlive allows multiple HTTP request/response cycles to run
through the same TCP connection, avoiding the TCP setup cost.
Typically, requests made on external resources benefit most from
KeepAlive (e.g. stylesheets fetched due to a reference from an
HTML).

But you have to weigh that cost with alternatives.  The downside of
KeepAlive is that it's based on time, so you'll almost certainly
have processes sitting idle.  If you run a separate media server,
KeepAlive is generally a waste, since subsequent requests go to a
separate process, and instead if just ties up the original process
for no gain.

In general, it's unusual to have such a heavy apache process with no
subsequent requests, so the docs weren't written with it in mind.


I see.


... another poke in the dark... are you serving flatpages and/or
static media via Django?


I'm not using the flatpages app if that's what you mean.

Most of my content is static in nature, generated on-demand from ReST
sources.  For those pages, the model checks the mod time of a
directory in the filesystem before deciding if the content in the
locmem cache is up-to-date.


Your settings.py and urls.py (leaving out sensitive stuff, of
course) would also help.


I can't thank you enough for being willing to crawl through my code
and configs.  BTW, I'm not posting my httpd.conf (yet) because (a)
it's spread across many files and (b) I don't feel very confident that
I wouldn't be making a security blunder.

Voil�:
 settings.py ---

ADMINS = (
   ('Dave Abrahams', 'myemail')
   # ('Your Name', '[EMAIL PROTECTED]'),
)

MANAGERS = ADMINS

#
# prepare settings that depend on where the project is being run.
#
from site_context import *

TEMPLATE_DEBUG = DEBUG

CACHE_BACKEND = 'locmem:///'

# A default for the view cache, etc.
CACHE_MIDDLEWARE_SECONDS = 60*10

# Local time zone for this installation. All choices can be found here:
# 
http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'US/Pacific'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
   'django.template.loaders.filesystem.load_template_source',
   'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
#'django.middleware.cache.CacheMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.middleware.doc.XViewMiddleware',
)

ROOT_URLCONF = 'boost_consulting.urls'
APPEND_SLASH = False

TEMPLATE_DIRS = (
   # Put strings here, like "/home/html/django_templates".
   # Always use forward slashes, even on Windows.
   'templates'
)

INSTALLED_APPS = (
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.admin',
   'django.contrib.comments',

   'boost_consulting.testimonials',
   'boost_consulting.news',
   'boost_consulting.pages',
)

-- urls.py 
from django.conf.urls.defaults import *
from news.models import News
from news.feeds import NewsFeed
from boost_consulting.settings import serve_media

feeds = {
   'news': NewsFeed
}
   
urlpatterns = patterns('',

   # Uncomment this for admin:
   (r'^admin/', include('django.contrib.admin.urls')),

   (r'^comments/', include('django.contrib.comments.urls.comments')),

   (r'^feed/(?P[-\w]+)', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
)

if serve_media:
   # Debug only - http://www.djangoproject.com/documentation/static_files/
   # explains why we 

Re: Why so slow?

2007-01-05 Thread Jeremy Dunck


On 1/5/07, Joseph Heck <[EMAIL PROTECTED]> wrote:

Everyone's looking at the web serving mechanisms, so let me ask a relatively
obvious question - are you doing anything complex database-wise on the page
that's being so slow? Perhaps one of the issues is a missing index or
something equivalent?


Oy, yeah, cache misses for the first few minutes...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with site domain in Admin interface

2007-01-05 Thread Tool69


Thank you Baxter,
you avoid me a big waste of time and effort. I was studing my Django
code, and couldn't find the answer.
The problem was solved in changing kib2.webfactionnal.com to 1, as you
said.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Joseph Heck

Everyone's looking at the web serving mechanisms, so let me ask a relatively
obvious question - are you doing anything complex database-wise on the page
that's being so slow? Perhaps one of the issues is a missing index or
something equivalent?

There's some good debugging information tied into pages that will show you
how long it took to do the SQL statements associated with any given page
render...

-joe

On 1/5/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:



On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote:
>
> "Jeremy Dunck" <[EMAIL PROTECTED]> writes:
>
...
> Sure.  If the traffic demands were high I could understand why we'd
> like to dedicate the process to Apache.  But I don't think they're
> high yet.  I am running quite a few services off this machine (Trac
> servers, Mailing lists, SVN) but they have relatively few users.

You said earlier that "top" seemed to not be CPU-bound.

What about "free"?  What about "lsof"?  I know paging seems
unrelated... which is why KeepAlive was my first shot.But the
"several minutes" thing sounds like Apache is spending a lot of time
before deciding to spin up extra children.  Can you generate load on
these other services (to tie up processes), then see performance with
and without KeepAlive?   Trying to repro that issue will be tough.
:-/


...
> > There's no need at all to run a separate machine for media.  Lightty
> > serving media files is crazy-fast.  As long as you have a separate IP
> > (and Apache is doing IP-based, rather than name-based, service),
>
> I'm somewhat unschooled in the IP-based/name-based distinction.  I
> read the docs, but I'm not sure they connected.  My server has one IP
> address.  I am running several Apache virtual servers on that IP
> address.  My configuration contains
>
>   NameVirtualHost: *:80
>
> so is that name-based?


Yeah, sorry.  Basically, the difference is whether your web server
sends responses based on IP only (in which case the vhost ServerName
is window dressing) or whether it's based on HTTP's HOST header, in
which case the response depends not only on IP, but also HOST.

In any case, you can still set them up to listen on separate ports,
even on the same IP.

> > server.port = 81
> > server.bind = "the.same.ip"

Then just change MEDIA_URL to be yourdomain.com:81, and you should be set.

No one will be using your media directly, probably, so the :81 won't
confuse people typing in URLs.  ;-)

>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with site domain in Admin interface

2007-01-05 Thread [EMAIL PROTECTED]


I'd look in the database and see what id kib2.webfactionnal.com has
versus what the comments have. I bet all the comments are looking for 1
(what example.com was) and kib2.webfactionnal.com is 2... in which
case, I'd probably just change kib2.webfactionnal.com to 1.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multiple projects one server

2007-01-05 Thread Robin Becker


David Zhou wrote:



On Jan 5, 2007, at 5:00 AM, Robin Becker wrote:

so these define the server used by the http stuff below, do I  
understand it correctly that the fcgi processes are setup to listen  
on the above ports?


Those are unix sockets, but correct.  The fcgi processes are listen  at 
those sockets.


If so does nginx provide some mechanism to start them up or is it  all 
handomatic?


I have a script that starts them up, but yeah, AFAIK, there isn't  
anything in nginx or Django that starts them automatically.

..
thanks David, real helpful
--
Robin Becker

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Jeremy Dunck


On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote:


"Jeremy Dunck" <[EMAIL PROTECTED]> writes:


...

Sure.  If the traffic demands were high I could understand why we'd
like to dedicate the process to Apache.  But I don't think they're
high yet.  I am running quite a few services off this machine (Trac
servers, Mailing lists, SVN) but they have relatively few users.


You said earlier that "top" seemed to not be CPU-bound.

What about "free"?  What about "lsof"?  I know paging seems
unrelated... which is why KeepAlive was my first shot.But the
"several minutes" thing sounds like Apache is spending a lot of time
before deciding to spin up extra children.  Can you generate load on
these other services (to tie up processes), then see performance with
and without KeepAlive?   Trying to repro that issue will be tough.
:-/


...

> There's no need at all to run a separate machine for media.  Lightty
> serving media files is crazy-fast.  As long as you have a separate IP
> (and Apache is doing IP-based, rather than name-based, service),

I'm somewhat unschooled in the IP-based/name-based distinction.  I
read the docs, but I'm not sure they connected.  My server has one IP
address.  I am running several Apache virtual servers on that IP
address.  My configuration contains

  NameVirtualHost: *:80

so is that name-based?



Yeah, sorry.  Basically, the difference is whether your web server
sends responses based on IP only (in which case the vhost ServerName
is window dressing) or whether it's based on HTTP's HOST header, in
which case the response depends not only on IP, but also HOST.

In any case, you can still set them up to listen on separate ports,
even on the same IP.


> server.port = 81
> server.bind = "the.same.ip"


Then just change MEDIA_URL to be yourdomain.com:81, and you should be set.

No one will be using your media directly, probably, so the :81 won't
confuse people typing in URLs.  ;-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with site domain in Admin interface

2007-01-05 Thread Tool69


Hi James,
no I did the faulty removing of "example.com" (loosing all my comments,
but that's not the worst), then I set my new one to
"kib2.webfactionnal.com". Now, I can't read any comments.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread [EMAIL PROTECTED]


On Jan 5, 2:54 am, David Abrahams <[EMAIL PROTECTED]> wrote:

I am developing a Django-based site, and it *really* seems to be
slow... sometimes.  It's running in an Apache virtual server on the



Any insight you might have is appreciated.


Are you sure it's not a client issue?

I had a problem with ffox 1.5 and 2.0 which i fixed disabling ffox IPV6
support and other stuff (maxrequests and so on). The site was crawling,
but it wasn't Django's fault.

Try testing with IE if you happen to have it handy.

Lorenzo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Handling bad URLs

2007-01-05 Thread [EMAIL PROTECTED]


Thanks!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RFC newforms usage

2007-01-05 Thread [EMAIL PROTECTED]


Hi all,

i started reimplementing my old manipulators code using newforms. Can u
guys give me some feedback on my usage of it?

What i wrote seems to me a lot of code for a 3 field form (even though
part of the bloat is due to date formatting)

Here's the code:
http://dpaste.com/hold/4382/

Also after i've deleted the object in the delete_academic_year function
i'd like to redirect to the add_academic_year method passing a message
without using the querystring and have the URL reflect the change and
display something like "You have successfully deleted the object" above
the new object form

The following is the template i'm using:
http://dpaste.com/hold/4386/

Thanks,
Lorenzo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Jeremy Dunck


On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote:
..

> Except that KeepAlive ties up processes waiting for further requests
> from a client, which may never come (and certainly won't if you run
> media separately as recommended.

So you're saying that basically the docs are wrong (not questioning
you; just trying to understand better)?


The docs aren't wrong, per se-- KeepAlive generally does result in a
performance improvement.  KeepAlive allows multiple HTTP
request/response cycles to run through the same TCP connection,
avoiding the TCP setup cost.  Typically, requests made on external
resources benefit most from KeepAlive (e.g. stylesheets fetched due to
a reference from an HTML).

But you have to weigh that cost with alternatives.   The downside of
KeepAlive is that it's based on time, so you'll almost certainly have
processes sitting idle.  If you run a separate media server, KeepAlive
is generally a waste, since subsequent requests go to a separate
process, and instead if just ties up the original process for no gain.

In general, it's unusual to have such a heavy apache process with no
subsequent requests, so the docs weren't written with it in mind.

... another poke in the dark... are you serving flatpages and/or
static media via Django?

Your settings.py and urls.py (leaving out sensitive stuff, of course)
would also help.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Handling bad URLs

2007-01-05 Thread James Bennett


On 1/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

I'm not sure why this throws a 500 error rather than a 404, but I'm
hoping somebody can help.


Typically, the pattern is to catch ObjectDoesNotExist and either
recover from it or raise Http404; ObjectDoesNotExist is there to let
you have a hook for catching non-existent lookups.

I wonder if maybe it would help if ObjectDoesNotExist were to become a
subclass of Http404, so that an uncaught ObjectDoesNotExist exception
would just become a 404...

--
"May the forces of evil become confused on the way to your house."
 -- George Carlin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Handling bad URLs

2007-01-05 Thread Julio Nobrega


 Use get_object_or_404() or make a try/raise block with raise Http404.

On 1/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


I'm not sure why this throws a 500 error rather than a 404, but I'm
hoping somebody can help.

On my site, each forum has a slug... site.com/foo-bar/

but if someone types in site.com/foobar/ it gives a 500 error.
Traceback says "DoesNotExist: Forum matching query does not exist."
which makes sense.

Relevant url is:
(r'^(?P[-\w]+)/$', 'views.topic_list'),

I'm trying to figure out how to capture a non forum_slug and either
route them to the right place if possible, or at least give them a 404.


--
Julio Nobrega - http://www.inerciasensorial.com.br

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread David Abrahams


"Jeremy Dunck" <[EMAIL PROTECTED]> writes:


On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote:
...

> Most likely, KeepAlive is holding processes unavailable while
> sitting idle.

How would I tell if that was happening?


Turn it off and see if performance suddenly becomes rediculously good.  :)


Tried that; it's hard to tell if it makes a difference.  Naturally
just after the server restarts performance is bad.  It eventually
becomes very good, but it does that too when KeepAlive is on.  As I
said earlier, I usually experience this slowness when I've been away
from the site for a while.  I could leave it off for a while and see
if that changes things, but it might take a day or more to get a good
sense of whether it makes a difference.


If you want more evidence, perhaps the status module would interest you.


Apache status module?  I could look at it, thanks.


> Next most likely is # of child processes.  Try fiddling with Min and
> MaxSpareServers.
>  http://httpd.apache.org/docs/2.0/mod/prefork.html

According to the docs that should only be necessary if I have very
heavy traffic.  I don't; far from it.  So I'm reluctant to mess with
those.


Except that KeepAlive ties up processes waiting for further requests
from a client, which may never come (and certainly won't if you run
media separately as recommended.


So you're saying that basically the docs are wrong (not questioning
you; just trying to understand better)?


The thing to remember is that apache+modpython+django+your app is a
very large process, and you should try to keep it busy doing Django
where possible.  Otherwise, you're wasting resources... swatting flies
with hammers, so to speak.


Sure.  If the traffic demands were high I could understand why we'd
like to dedicate the process to Apache.  But I don't think they're
high yet.  I am running quite a few services off this machine (Trac
servers, Mailing lists, SVN) but they have relatively few users.


> Next most likely is that you're serving media and django on the
> save httpd.

I definitely am.  However, on a relatively low-traffic server like
mine it's hard to imagine that it's causing the kind of slow responses
I sometimes see.  Maybe I'm deluding myself?


If your processes are tied up listening to a client that's not
talking, your server will sit completely idle doing nothing for as
long as KeepAlive makes them.

Want to see ridiculously bad performance?  Make 1 server process, set
KeepAlive, and server media from it.  It'll take (timeout * # of http
request seconds) to serve if your client doesn't actually utilize the
keepalive feature.


Okay, I get that.


I could probably install lighthttpd, although getting that running
alongside Apache seems like a minefield (just a feeling; I have no
data).


There's no need at all to run a separate machine for media.  Lightty
serving media files is crazy-fast.  As long as you have a separate IP
(and Apache is doing IP-based, rather than name-based, service), 


I'm somewhat unschooled in the IP-based/name-based distinction.  I
read the docs, but I'm not sure they connected.  My server has one IP
address.  I am running several Apache virtual servers on that IP
address.  My configuration contains

 NameVirtualHost: *:80

so is that name-based?


it's quite simple.

In your lighttpd.conf:
===
server.port = 80
server.bind = "your.media.ip"


Yeah, I don't have a separate IP for media.  I don't know what that
would cost me, either.


server.username = "same as apache"
server.groupname = "same as apache"
server.pid-file = "/var/run/lighttpd.pid"
server.dir-listing = "disable"
server.document-root = "/path/to/media_root/"
server.errorlog = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"
#mime support if you want it:
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
=

Then set MEDIA_URL = media.yourdomain.com
and make a DNS entry pointing media.yourdomain.com to your.media.ip.


The LightHttpd docs make it sound like it
would be better than apache for all _my_ webserver needs, but using it
that way with Django sounds like it's still pretty experimental at
best.


Apparently a fair number of people are using fcgi, though I'm not one of them.

Did you see this?
http://www.djangoproject.com/documentation/fastcgi/#lighttpd-setup


Hmm, I guess I did once.  I guess that means it isn't as experimental
as I thought, thanks.

In any case, you seem reluctant to make changes, 


Well, I'm just running out of time for experimentation, but maybe I
have to bite the bullet.


but IMHO, the best
thing you can do is keep a copy of your existing (bad) conf and do a
series of A/B performance tests, starting with the suggestions here
and in Jacob's post.  :)


Not a bad plan.


To help future suggestions, what apache and OS versions are you running?


Apache 2.2 on FreeBSD 6.1

Thanks again for your attention.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


--~--~-~--~---

Re: Hidden variable lookup failures and template performance

2007-01-05 Thread Karen


Bah, I feel guilty.  I ran into this several months ago and reported it
here, got some feedback that I should open an issue on it but never
followed up.  So now I have:

http://code.djangoproject.com/ticket/3235

The suggestions you make for django user's code to avoid the
performance hit are valid, but I don't think django itself ought to
include a potentially big performance hit for looking up a non-existant
variable, so hopefully this will be addressed in the base code as well.

Cheers,
Karen


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with site domain in Admin interface

2007-01-05 Thread James Bennett


On 1/5/07, Tool69 <[EMAIL PROTECTED]> wrote:

It was "example.com", so I made the changes, but now all my comments
have disappeared and I just can't post any new one : I can write them,
preview them, but they are not on my blog anymore.


Did you just edit the domain name in the default 'example.com' Site
object, or did you create another Site object and start using that?
Any comments previously posted would be tied to the default
'example.com' Site object, so if you created a different Site
instance, you might no longer see old comments show up publicly.

--
"May the forces of evil become confused on the way to your house."
 -- George Carlin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread David Abrahams


"DavidA" <[EMAIL PROTECTED]> writes:


Is it possible your Apache server is doing reverse DNS lookups on the
GET requests and the lookup is failing for the client machine? I seem
to remember older versions of Apache having this on by default. 


It's Apache22, but I don't have any explicit setting in my httpd.conf.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problems with site domain in Admin interface

2007-01-05 Thread Tool69


Hi,
I needed to make some changes in my Admin as I saw I've not set the
right Site domain.
It was "example.com", so I made the changes, but now all my comments
have disappeared and I just can't post any new one : I can write them,
preview them, but they are not on my blog anymore.
My Admin interface only shows the number of comments, without details,
you can see this here:
h**p://kib2.free.fr/temp/admin.png

Have you got any ideas ?
Thanks,
6TooL9


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Handling bad URLs

2007-01-05 Thread [EMAIL PROTECTED]


I'm not sure why this throws a 500 error rather than a 404, but I'm
hoping somebody can help.

On my site, each forum has a slug... site.com/foo-bar/

but if someone types in site.com/foobar/ it gives a 500 error.
Traceback says "DoesNotExist: Forum matching query does not exist."
which makes sense.

Relevant url is:
(r'^(?P[-\w]+)/$', 'views.topic_list'),

I'm trying to figure out how to capture a non forum_slug and either
route them to the right place if possible, or at least give them a 404.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



python syntax highlighter style change issue

2007-01-05 Thread stoKes


hi all,

using a little bit of code snippets from pygments demo app views and of
course using pygments with django for syntax highlighting. im running
into an issue where no matter what style ive selected i can't get it to
highlight properly.. to get around this ive manually copied a
stylesheet from pygments.pocoo.org and using one style at the moment.

if anyone has any experience with this i'd appreciate the help, here is
my templates/views

{% extends "base.html" %}
{% block title %}
{{ code.id }}
{% endblock %}
{% block content %}
{% load sitevars %}
Entry {{ code.id }}

Paste some code!

Style
   
   {% for style in styles %}
   {{ style }}
   {% endfor %}
   
   


   
   {{ code.hlcode }}
   

{% endblock %}


and my view
# Create your views here.
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.contrib import auth
from django.contrib.auth.models import User
from djangoprojects.cpaste.models import CPaste

from pygments import highlight
from pygments.lexers import get_lexer_by_name,LEXERS
from pygments.formatters import HtmlFormatter
from pygments.styles import STYLE_MAP

from datetime import datetime

#
# globals
HTML_STYLE='trac'
fmter =
HtmlFormatter(style=HTML_STYLE,cssclass='syntax',encoding='utf-8')

lexers = [(x[1], x[2]) for x in LEXERS.values()]
lexers.sort()

lx_name = dict((lx[1][0],lx[0]) for lx in lexers)
lx_name[''] = ''

def detail(request,code_id):
   if not request.user.is_authenticated():
   user = ''
   else:
   user = request.user
   uid = User.objects.get(username=request.user)
   try:
   code = CPaste.objects.get(pk=code_id)
   _do_hl(code)
   code.save()
   except CPaste.DoesNotExist:
   return HttpResponseRedirect("/toolbox/cpaste/")
   style = request.GET.get('style')
   if style and style in STYLE_MAP:
   request.session['style'] = style
   else:
   style = request.session.get('style', 'friendly')

   return render_to_response('cpaste/detail.html',
dict(code=code,styles=STYLE_MAP.keys(),curstyle=style,user=user))

def _do_hl(code):
   lexer=get_lexer_by_name(code.sourcelang)
   code.hlcode =
highlight(code.sourcecode,lexer,fmter).decode('utf-8')

so as far as saving the content based on style that seems to work, but
i can't figure out how to push the selected style back into the
template? from what i noticed on pygments.pocoo.org is that it writes
to a /media/pygments_style.css each time a different style is
requested.

thx
adam


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Jeremy Dunck


On 1/5/07, David Abrahams <[EMAIL PROTECTED]> wrote:
...

> Most likely, KeepAlive is holding processes unavailable while
> sitting idle.

How would I tell if that was happening?


Turn it off and see if performance suddenly becomes rediculously good.  :)

If you want more evidence, perhaps the status module would interest you.


> Next most likely is # of child processes.  Try fiddling with Min and
> MaxSpareServers.
>  http://httpd.apache.org/docs/2.0/mod/prefork.html

According to the docs that should only be necessary if I have very
heavy traffic.  I don't; far from it.  So I'm reluctant to mess with
those.


Except that KeepAlive ties up processes waiting for further requests
from a client, which may never come (and certainly won't if you run
media separately as recommended.

The thing to remember is that apache+modpython+django+your app is a
very large process, and you should try to keep it busy doing Django
where possible.  Otherwise, you're wasting resources... swatting flies
with hammers, so to speak.


> Next most likely is that you're serving media and django on the save httpd.

I definitely am.  However, on a relatively low-traffic server like
mine it's hard to imagine that it's causing the kind of slow responses
I sometimes see.  Maybe I'm deluding myself?


If your processes are tied up listening to a client that's not
talking, your server will sit completely idle doing nothing for as
long as KeepAlive makes them.

Want to see ridiculously bad performance?  Make 1 server process, set
KeepAlive, and server media from it.  It'll take (timeout * # of http
request seconds) to serve if your client doesn't actually utilize the
keepalive feature.


I could probably install lighthttpd, although
getting that running alongside Apache seems like a minefield (just a
feeling; I have no data).


There's no need at all to run a separate machine for media.  Lightty
serving media files is crazy-fast.  As long as you have a separate IP
(and Apache is doing IP-based, rather than name-based, service), it's
quite simple.

In your lighttpd.conf:
===
server.port = 80
server.bind = "your.media.ip"
server.username = "same as apache"
server.groupname = "same as apache"
server.pid-file = "/var/run/lighttpd.pid"
server.dir-listing = "disable"
server.document-root = "/path/to/media_root/"
server.errorlog = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"
#mime support if you want it:
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
=

Then set MEDIA_URL = media.yourdomain.com
and make a DNS entry pointing media.yourdomain.com to your.media.ip.


The LightHttpd docs make it sound like it
would be better than apache for all _my_ webserver needs, but using it
that way with Django sounds like it's still pretty experimental at
best.


Apparently a fair number of people are using fcgi, though I'm not one of them.

Did you see this?
http://www.djangoproject.com/documentation/fastcgi/#lighttpd-setup

In any case, you seem reluctant to make changes, but IMHO, the best
thing you can do is keep a copy of your existing (bad) conf and do a
series of A/B performance tests, starting with the suggestions here
and in Jacob's post.  :)

To help future suggestions, what apache and OS versions are you running?

 -Jeremy

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread Jeremy Dunck


On 1/5/07, DavidA <[EMAIL PROTECTED]> wrote:


Is it possible your Apache server is doing reverse DNS lookups on the
GET requests and the lookup is failing for the client machine? I seem
to remember older versions of Apache having this on by default. You can
turn it off with this in your httpd.conf file.

HostnameLookups off

Of course, I'm stabbing in the dark somewhat...


Yeah, your httpd.conf would help...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread DavidA


Is it possible your Apache server is doing reverse DNS lookups on the
GET requests and the lookup is failing for the client machine? I seem
to remember older versions of Apache having this on by default. You can
turn it off with this in your httpd.conf file.

   HostnameLookups off

Of course, I'm stabbing in the dark somewhat...
-Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



free games

2007-01-05 Thread anand8


Download Free Games! - http://surl.in/HLFRG238206SVRAKSX


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread David Abrahams


"Jeremy Dunck" <[EMAIL PROTECTED]> writes:


On 1/4/07, David Abrahams <[EMAIL PROTECTED]> wrote:
...

If I log into the server and run "top" while trying to access pages, I
don't see any alarming jumps in CPU load; the hungriest processes
typically stay in single-digit (or below) percentages of CPU usage, so
I doubt profiling is going to be much use.  I don't really know where
to start in debugging this.


Hi Jeremy,

Thanks for responding...


Most likely, KeepAlive is holding processes unavailable while
sitting idle.


How would I tell if that was happening?


Next most likely is # of child processes.  Try fiddling with Min and
MaxSpareServers.
 http://httpd.apache.org/docs/2.0/mod/prefork.html


According to the docs that should only be necessary if I have very
heavy traffic.  I don't; far from it.  So I'm reluctant to mess with
those.


Next most likely is that you're serving media and django on the save httpd.


I definitely am.  However, on a relatively low-traffic server like
mine it's hard to imagine that it's causing the kind of slow responses
I sometimes see.  Maybe I'm deluding myself?


More suggestions:
http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/


Okay, I remember reading that page already.  I can't afford a separate
media server machine.  I could probably install lighthttpd, although
getting that running alongside Apache seems like a minefield (just a
feeling; I have no data).  The LightHttpd docs make it sound like it
would be better than apache for all _my_ webserver needs, but using it
that way with Django sounds like it's still pretty experimental at
best.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why so slow?

2007-01-05 Thread David Abrahams


"Jeremy Dunck" <[EMAIL PROTECTED]> writes:


On 1/4/07, David Abrahams <[EMAIL PROTECTED]> wrote:
...

If I log into the server and run "top" while trying to access pages, I
don't see any alarming jumps in CPU load; the hungriest processes
typically stay in single-digit (or below) percentages of CPU usage, so
I doubt profiling is going to be much use.  I don't really know where
to start in debugging this.


Most likely, KeepAlive is holding processes unavailable while
sitting idle.


How would I tell if that was happening?


Next most likely is # of child processes.  Try fiddling with Min and
MaxSpareServers.
 http://httpd.apache.org/docs/2.0/mod/prefork.html


According to the docs that should only be necessary if I have very
heavy traffic.  I don't; far from it.  So I'm reluctant to mess with
those.


Next most likely is that you're serving media and django on the save httpd.


I definitely am.  However, on a relatively low-traffic server like
mine it's hard to imagine that it's causing the kind of slow responses
I sometimes see.  Maybe I'm deluding myself?


More suggestions:
http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/


Okay, I remember reading that page already.  I can't afford a separate
media server machine.  I could probably install lighthttpd, although
getting that running alongside Apache seems like a minefield (just a
feeling; I have no data).  The LightHttpd docs make it sound like it
would be better than apache for all _my_ webserver needs, but using it
that way with Django sounds like it's still pretty experimental at
best.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Can I do this. Forms and Manipulators.

2007-01-05 Thread [EMAIL PROTECTED]


I have three models, a participant, contact, and contact detal.
Participant is basically a user table, contact is a list of
contact_types (ie, web links, emails etc) and contact detail is a
detail of the contacts for a particular participant -

the the contact detail class is below:

class ContactDetail(models.Model):
   contact_detail_id = models.AutoField(primary_key=True,
editable=False)
   contact = models.ForeignKey(Contact)
   participant = models.ForeignKey(Participant)
   contact_value = models.CharField(blank=True, maxlength=765)
   contact_comment = models.CharField(blank=True,null=True,
maxlength=12000)

   def __str__(self):
   return '%s %s %s' % (self.contact_value, self.contact,
self.participant)

   class Meta:
   db_table = 'CONTACT_DETAIL'
   class Admin:
  pass

What I want to do is have a form to edit the contact_detaisl for a
participant - something like

then a button to update -
I would also like a back form line that has the dropdown for contact
types, plus 2 blank fields  with an add button.


My though was to build it as a single form to edit one contact detail -
then use a for loop to  put multiple forms on the page, so the page
looks like this


AIM  [EMAIL PROTECTED]  no comment  [button update]
MSN [EMAIL PROTECTED]  no comment  [button update]
GTalk [EMAIL PROTECTED]  no comment  [button update]
  [form field ]  [ form field]  [Button Add]

Is this a valid idea for the solution or are there other ways to do
this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple models on one form

2007-01-05 Thread Russell Keith-Magee


On 1/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


I am trying to get your solution 1 to work for the case of multiple
instances of the same model. The forms looks good, but the problem is
that all fields have the same name (because the forms are generated
from the same model). Is there any way around that? Or do I have to
write a custom manipulator in this case? It seems as if I'm SOOO
close...


I can't think of an easy way to add a prefix to one of the
manipulators, so In this case, I think you will need to resort to a
custom manipulator.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



have your intimate date

2007-01-05 Thread anand8


Search Profiles - FREE! Intimate Dating. Start Chatting within seconds
- http://surl.in/HLMAT238206SVRAKSX


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multiple projects one server

2007-01-05 Thread David Zhou



On Jan 5, 2007, at 5:00 AM, Robin Becker wrote:

so these define the server used by the http stuff below, do I  
understand it correctly that the fcgi processes are setup to listen  
on the above ports?


Those are unix sockets, but correct.  The fcgi processes are listen  
at those sockets.


If so does nginx provide some mechanism to start them up or is it  
all handomatic?


I have a script that starts them up, but yeah, AFAIK, there isn't  
anything in nginx or Django that starts them automatically.


---
David Zhou
[EMAIL PROTECTED]




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What's the proper use of LazyDate?

2007-01-05 Thread Russell Keith-Magee


On 1/5/07, James Bennett <[EMAIL PROTECTED]> wrote:


I can't find it now, but I have this odd feeling that somewhere I saw
mention that LazyDate was/would be/should be deprecated in favor of
just using the appropriate methods from the datetime module (e.g.,
instead of using a LazyDate object as a default for a DateTimeField,
use datetime.datetime.now, and so on).

Or am I getting all confused again?


The reference you are probably thinking of is the field_defaults
modeltest. It doesn't mention LazyDate - it justs says that you could
use datetime.now as a callable default value. The only place
'LazyDate' turns up is in the model API.

datetime.now (passed as a callable) isn't a complete solution, though.
You can't use a callable in a query argument - at least, not in the
current implementation of queries. A similar problem exists for field
initial values.

I can't see any particular reason that a callable shouldn't be allowed
just about anywhere in a model definition or query definition. It's
just more work to allow it. But this would allow us to officially
deprecate LazyDate (which appeals to me because of the number of times
LazyDate has bitten me on the posterior testing bugfixes, etc). Anyone
want to volunteer?

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error Template

2007-01-05 Thread Lawrence Oluyede


Sorry I forgot to specify a thing.

The thing is to play with django on the console you need an actual
application to poke with. In order to Django to know how to deal with
that you have to tell it where resides the settings.py of your app so
you can play with its model and so on. "python manage.py shell" does
that for you. When I told you about the current directory "." I meant
telling Django where settings.py is like
DJANGO_SETTINGS_MODULE=settings or "iti.settings". I wasn't sure what
the env variable wanted as its value

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error Template

2007-01-05 Thread Jose Federico Muñoz Rubio
I try but :

[EMAIL PROTECTED]:~/iti$ export DJANGO_SETTINGS_MODULE=.
[EMAIL PROTECTED]:~/iti$ python
Python 2.4.4c1 (#2, Oct 11 2006, 20:00:03) 
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.template import Template
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 907, in ?
add_to_builtins('django.template.defaultfilters')
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 904, in add_to_builtins
builtins.append(get_library(module_name))
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 893, in get_library
mod = __import__(module_name, {}, {}, [''])
  File
"/usr/lib/python2.4/site-packages/django/template/defaultfilters.py",
line 5, in ?
from django.utils.translation import gettext
  File
"/usr/lib/python2.4/site-packages/django/utils/translation/__init__.py",
line 3, in ?
if settings.USE_I18N:
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
27, in __getattr__
self._import_settings()
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
54, in _import_settings
self._target = Settings(settings_module)
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
80, in __init__
mod = __import__(self.SETTINGS_MODULE, {}, {}, [''])
ValueError: Empty module name
>>> 


El vie, 05-01-2007 a las 13:32 +0100, Lawrence Oluyede escribió:
> > raise EnvironmentError, "Could not import settings '%s' (Is it on
> > sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
> > EnvironmentError: Could not import settings 'iti.settings' (Is it on
> > sys.path? Does it have syntax errors?): No module named iti.settings
> 
> 
> AFAIK that's because you are in the "iti" directory which means you
> already are in the "iti" package/module. Try using "." as the value of
> the environment variable
> 
-- 
-
José Federico Muñoz Rubio <[EMAIL PROTECTED]>
Área de Sistemas
Instituto Tecnológico de Informática (UPV)
http://www.iti.upv.es
-


signature.asc
Description: Esta parte del mensaje está firmada	digitalmente


Re: Error Template

2007-01-05 Thread Lawrence Oluyede



raise EnvironmentError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'iti.settings' (Is it on
sys.path? Does it have syntax errors?): No module named iti.settings



AFAIK that's because you are in the "iti" directory which means you
already are in the "iti" package/module. Try using "." as the value of
the environment variable

--
Lawrence
http://www.oluyede.org/blog
http://www.neropercaso.it

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Error Template

2007-01-05 Thread Jose Federico Muñoz Rubio
Hi, I read DJANGO BOOK and Chapter 4: The Django template system. I read
Creating template objects and :

#python
Python 2.4.4c1 (#2, Oct 11 2006, 20:00:03) 
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.template import Template
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 907, in ?
add_to_builtins('django.template.defaultfilters')
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 904, in add_to_builtins
builtins.append(get_library(module_name))
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 893, in get_library
mod = __import__(module_name, {}, {}, [''])
  File
"/usr/lib/python2.4/site-packages/django/template/defaultfilters.py",
line 5, in ?
from django.utils.translation import gettext
  File
"/usr/lib/python2.4/site-packages/django/utils/translation/__init__.py",
line 3, in ?
if settings.USE_I18N:
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
27, in __getattr__
self._import_settings()
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
52, in _import_settings
raise EnvironmentError, "Environment variable %s is undefined." %
ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
undefined.

Next 

[EMAIL PROTECTED]:~/iti$ export DJANGO_SETTINGS_MODULE=iti.settings
[EMAIL PROTECTED]:~/iti$ python
Python 2.4.4c1 (#2, Oct 11 2006, 20:00:03) 
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.template import Template
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 907, in ?
add_to_builtins('django.template.defaultfilters')
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 904, in add_to_builtins
builtins.append(get_library(module_name))
  File "/usr/lib/python2.4/site-packages/django/template/__init__.py",
line 893, in get_library
mod = __import__(module_name, {}, {}, [''])
  File
"/usr/lib/python2.4/site-packages/django/template/defaultfilters.py",
line 5, in ?
from django.utils.translation import gettext
  File
"/usr/lib/python2.4/site-packages/django/utils/translation/__init__.py",
line 3, in ?
if settings.USE_I18N:
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
27, in __getattr__
self._import_settings()
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
54, in _import_settings
self._target = Settings(settings_module)
  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line
82, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'iti.settings' (Is it on
sys.path? Does it have syntax errors?): No module named iti.settings

Thanks


-- 
-
José Federico Muñoz Rubio <[EMAIL PROTECTED]>
Área de Sistemas
Instituto Tecnológico de Informática (UPV)
http://www.iti.upv.es
-


signature.asc
Description: Esta parte del mensaje está firmada	digitalmente


Re: multiple projects one server

2007-01-05 Thread Robin Becker


David Zhou wrote:



I'm running nginx + fcgi for Django, so the below is in nginx's  config 
format.  But I'm assuming that lighttpd should be able to do  something 
similar.


Basically, in nginx, you can specify various upstream pools. For  example:

upstream blah {
server unix:/tmp/blah.com_1.sock;
server unix:/tmp/blah.com_2.sock;
}

upstream foo {
server unix:/tmp/foo.com_1.sock;
server unix:/tmp/foo.com_2.sock;
}



so these define the server used by the http stuff below, do I understand it 
correctly that the fcgi processes are setup to listen on the above ports?


If so does nginx provide some mechanism to start them up or is it all 
handomatic?



then in the site definitions:

server {
listen  80;
server_name blah.com;

location / {
#insert FCGI params stuff here
...
##
fastcgi_pass blah;
}
}

server {
listen  80;
server_name foo.com;

location / {
#insert FCGI params stuff here
...
##
fastcgi_pass foo;
}
}

...

--
Robin Becker

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Hidden variable lookup failures and template performance

2007-01-05 Thread akaihola


Here's an issue to be aware of wrt template performance:

I noticed that one of my templates was getting really slow. I profiled
it and it seemed to spend lots of time calling the __str__ method of
one of my models. The method contains a query for a related object,
which slowed things down quite a bit.

The mystery was, why was __str__ called in the first place, since my
template never prints out instances of that particular models, but only
accesses its properties directly.

The root cause of the slowdown was an {% ifnotequal myobj None %} tag,
which causes a variable lookup failure since 'None' is not part of the
context. You can't compare None values this way in Django of course,
and I should have known that, and in this particular case changing the
condition to {% if myobj %} works just fine too; problem solved and
customer happy.

I was still left intrigued about the __str__ call, and with some
debugging I made the following observations:

The reason for the __str__ call lies in the default Model.__repr__
method (django/db/models/base.py:79 in Django r4269), which ends up
evaluating '%s' % self as a part of the string it builds.

Why was __repr__ called then?

It turns out that even though failed variable lookups in many cases
silently evaluate as empty strings in Django templates, exceptions are
raised and caught behind the scenes, and to generate some of the
exception messages calls to model methods are required. In my case the
__repr__ call was triggered in the resolve_variable function
(django/template/__init__.py:663 in r4269) when 'None' was not found in
the context. Actually, if I'm not mistaken, __repr__ is called
recursively for every object in the context tree!

So, to avoid template performance problems, one should make sure that:
- no unnecessary variable lookup failures occur
- model __str__ methods are lightweight
- or, alternatively, lightweight __repr__ methods are defined for
models

This kind of performance problems are tricky to profile and debug, so
some help from Django's side would be useful. Any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What's the proper use of LazyDate?

2007-01-05 Thread Kenneth Gonsalves



On 05-Jan-07, at 1:34 PM, James Bennett wrote:


Or am I getting all confused again?


only the forces of evil get confused ;-)


--
"May the forces of evil become confused on the way to your house."
 -- George Carlin


--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What's the proper use of LazyDate?

2007-01-05 Thread James Bennett


On 1/4/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:

There is a tangential reference to LazyDate in the model API
documentation, but otherwise, this is an area where some documentation
could be useful. I've opened a ticket (#3231) for this issue.


I can't find it now, but I have this odd feeling that somewhere I saw
mention that LazyDate was/would be/should be deprecated in favor of
just using the appropriate methods from the datetime module (e.g.,
instead of using a LazyDate object as a default for a DateTimeField,
use datetime.datetime.now, and so on).

Or am I getting all confused again?

--
"May the forces of evil become confused on the way to your house."
 -- George Carlin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---