MEDIA_URL and the trailing slash (and a broken pipe or two)

2007-09-19 Thread Dave Lowe

I'm running into issues with the MEDIA_URL and that cursed trailing
slash. Here's what the documentation says about MEDIA_URL:

"Note that this should have a trailing slash if it has a path
component." Good examples given are: http://media.lawrence.com and
http://www.example.com/static/

I've found recently that my get_IMAGE_FIELD_url() methods don't work
correctly if that trailing slash isn't there unless it's a domain like
in the first example. But it's problematic for every situation where
I'm trying to use that MEDIA_URL in a template, like this:

link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}/css/
master.css" /

On my production server, the media is served from a subdomain so this
works great. But on my development server, it's served from a path
like in the second example above. So what I'm getting suddenly is a
broken pipe (32) because there are two slashes in a row (http://
www.example.com/static//css/master.css). I'm pretty sure that in the
past I've gotten around this before by simply omitting the trailing
slash, which fixes this but breaks the get_url() methods.

I have the feeling I'm missing something. What does everyone else do
to get around 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: Django deployment options

2007-09-19 Thread Kenneth Gonsalves


On 20-Sep-07, at 9:01 AM, Graham Dumpleton wrote:

>> one caveat here - if you are running a site on shared hosting with
>> soft RAM limit - like the 40 MB webfaction account, then it is wise
>> to bypass mod_python for media to avoid those nasty monday morning
>> mails about exceeding your limits and upgrading your account. This
>> applies to sites of even 5-10 hits a day. Note, I am not criticising
>> webfaction - they rock.
>
> To perhaps clarify on what I believe you are saying so people don't
> get the wrong impression, it is not about not using mod_python, but
> configuring Apache to serve the static files directly, rather than
> using Python functionality within a specific framework to return them.

yes - precisely what I am saying

-- 

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: Django deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 12:52 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 20-Sep-07, at 8:09 AM, Graham Dumpleton wrote:
>
> > All those warnings about using the same Apache to serve static
> > documents as Django are generally totally meaningless to the average
> > user. This is because the load on an average Apache site is no where
> > near enough for it to be of concern.
>
> one caveat here - if you are running a site on shared hosting with
> soft RAM limit - like the 40 MB webfaction account, then it is wise
> to bypass mod_python for media to avoid those nasty monday morning
> mails about exceeding your limits and upgrading your account. This
> applies to sites of even 5-10 hits a day. Note, I am not criticising
> webfaction - they rock.

To perhaps clarify on what I believe you are saying so people don't
get the wrong impression, it is not about not using mod_python, but
configuring Apache to serve the static files directly, rather than
using Python functionality within a specific framework to return them.
This applies to mod_wsgi as well as mod_python.

As an example, for mod_wsgi, you would use the following configuration
to ensure that media files are served directly by Apache and not by
Django (if so configured).

Alias /media/ /usr/local/django/mysite/media/


Order deny,allow
Allow from all


WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi


Order deny,allow
Allow from all


In other words, Apache directly serves static files under the media
directly and Django is not involved.

The reason for doing this is that often Python web frameworks will
read in a complete static file in order to return it. Thus the
complete files contents are in memory. Worse is that with mod_python,
since this is a Python string object, in order for Apache to be able
to output it through its output filtering system, it is necessary to
copy it into Apache managed memory. The result is that your memory use
then increases to two times the size of the file.

This might be avoided to a degree if the underlying WSGI framework
being used supports the wsgi.file_wrapper extension and the Python
framework actually uses it. Even then, the WSGI adapter may still need
to be integrated quite well with the web server, to avoid having to
still read the file contents into memory, even if a bit at a time, and
avoid the double memory overhead for each block.

In short you avoid all of these problems by ensuring that you never
have the Python web framework serve static files, instead, use the
appropriate Alias/Directory Apache directives to have Apache serve
them for you. Memory use will not be an issue in this instance as
Apache will send the file in blocks and flush out a block before
sending the next block. The only thing that would generally upset this
would be if there was an Apache output filter installed which was
needing to buffer up the whole file contents, or more than a single
block in order to do something.

Anyway, hope this explains things a bit better as to what the advice
was about and why it was given.

Graham


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



baffling i18n problem after unicode update

2007-09-19 Thread Kenneth Gonsalves

hi,

I have choices like this:

HEALTH_CHOICES = (
 ('G',_("Good")),
 ('A',_("Average")),
 ('P',_("Poor")),
 )
my site is english and finnish. These choices are used in several  
models. When finnish is on, they get translated in the web interface.  
I also generate reports in reportlab. In one report, choices shows up  
correctly if the report is in english. In finnish, the choice is  
translated and prints if it is "Average" or "Poor" - but if the  
choice is "Good", it does not appear in the report - it is blank. I  
cant even begin to think how to solve this - it was ok before  
updating to unicode. In all other reports with reportlab, "Good" gets  
translated and shows up. Any ideas?

-- 

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: Odd behavior while trying to test for cookie support

2007-09-19 Thread josePhoenix

I just realized that google groups totally mangled the linebreaks with
wordwrapping and similar.

Here's the same on dpaste: http://dpaste.com/20145/

jose

On Sep 19, 10:48 pm, [EMAIL PROTECTED] wrote:
> Hello, all.
>
> I have a login function for my site that is supposed to test for
> cookie support with request.session.set_test_cookie() and friends, but
> I cannot seem to get request.session.test_cookie_worked() to return
> True.. ever... Just trying to print the value of
> request.session['testcookie'] resulted in a KeyError, so presumably
> the problem has to do with saving the sessions somewhere between
> requests.
>
> Sessions do appear to work for the rest of my app, and the
> contrib.auth.views login view behaves as predicted, but something
> about my code seems to cause this lack of working-ness. I have asked
> in IRC, but after trying a bunch of things I was advised to ask here.
> Included are my login view, activation view, and a view I made that
> contains only the cookie-related stuff.
>
> ### Here's my login function:
>
> def login(request):
> "Displays the login form and handles the login action."
> redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '')
> if request.POST:
> if not request.session.test_cookie_worked(): ## I added this
> line to test with. It always raises the exception :\ I wasn't checking
> the for cookies working before (oops!), so I didn't notice that.
> raise Exception
> form = AuthenticationForm(request.POST)
> if form.is_valid():
> # Light security check -- make sure redirect_to isn't
> garbage.
> if not redirect_to or '://' in redirect_to or ' ' in
> redirect_to:
> from django.conf import settings
> redirect_to = settings.LOGIN_REDIRECT_URL
> user =
> authenticate(username=form.cleaned_data['username'],
> password=form.cleaned_data['password'])
> if user is not None:
> if user.is_active:
> request.session.delete_test_cookie()
> login(request, user)
> return HttpResponseRedirect(redirect_to)
> else:
> return render_to_response('user_area/login.html',
> {'form': form,
>
> REDIRECT_FIELD_NAME: redirect_to,
>
> 'redirect_field_name': REDIRECT_FIELD_NAME,
>
> 'disabled': True},
>
> context_instance=RequestContext(request))
> else:
> return render_to_response('user_area/login.html',
> {'form': form,
>
> REDIRECT_FIELD_NAME: redirect_to,
>
> 'redirect_field_name': REDIRECT_FIELD_NAME,
>
> 'authfail': True},
>
> context_instance=RequestContext(request))
> else:
> return render_to_response('user_area/login.html', {'form':
> form,
>
> REDIRECT_FIELD_NAME: redirect_to,
>
> 'redirect_field_name': REDIRECT_FIELD_NAME,},
>
> context_instance=RequestContext(request))
> else:
> form = AuthenticationForm()
> request.session.set_test_cookie()
> return render_to_response("user_area/login.html", {
> 'form': form,
> REDIRECT_FIELD_NAME: redirect_to,
> 'redirect_field_name': REDIRECT_FIELD_NAME,
> }, context_instance=RequestContext(request))
>
> ### Here's my activate function, which also sets a test cookie because
> it doubles as a login form
> def activate(request, hash):
> #u = get_object_or_404(User, userprofile__hash__exact=hash,
> is_active__exact=False)
> u = get_object_or_404(User, userprofile__hash__exact=hash)
> u.is_active = True
> u.get_profile().hash = None
> u.save()
>
> redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '')
> form = AuthenticationForm()
> request.session.set_test_cookie()
> print request.session['testcookie'] # prints 'worked'
>
> return render_to_response("user_area/login.html", {
> 'form': form,
> 'activated': True,
> }, context_instance=RequestContext(request))
>
> ### Here is the function that isolates the cookie testing stuff. It
> also doesn't work the way it should
> def test_cookie(request):
> if request.POST:
> if not request.session.test_cookie_worked():
> raise Exception
> request.session.delete_test_cookie()
> return render_to_response("user_area/login.html", {
>  'activated': True,
>  },
> context_instance=RequestContext(request))
> else:
> form = AuthenticationForm()
> request.session.set_test_cookie()
> return render_to_response("user_area/test.html", {
> 'form': form,
> }, context_instance=RequestContext(request))
>
> Any help or suggestions would be much appreciated!
>
> jose


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to 

答复: Where can I find the templatetag called "humanize" in Django application components "django-registration "

2007-09-19 Thread beck917

Thx a lot...I think I miss that chapter,sorry..

This problem has been solved..

-邮件原件-
发件人: django-users@googlegroups.com [mailto:[EMAIL PROTECTED]
代表 James Bennett
发送时间: 2007年9月20日 10:55
收件人: django-users@googlegroups.com
主题: Re: Where can I find the templatetag called "humanize" in Django
application components "django-registration "


On 9/19/07, beck917 <[EMAIL PROTECTED]> wrote:
> Where can I find the templatetag called "humanize" in Django application
> components "django-registration "

By looking at Django's documentation:

http://www.djangoproject.com/documentation/add_ons/#humanize

I thought I might finally be safe removing the glaring warning about
not trying to use the example templates, but perhaps it needs to go
back in.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct.
"



--~--~-~--~~~---~--~~
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 can I find the templatetag called "humanize" in Django application components "django-registration "

2007-09-19 Thread James Bennett

On 9/19/07, beck917 <[EMAIL PROTECTED]> wrote:
> Where can I find the templatetag called "humanize" in Django application
> components "django-registration "

By looking at Django's documentation:

http://www.djangoproject.com/documentation/add_ons/#humanize

I thought I might finally be safe removing the glaring warning about
not trying to use the example templates, but perhaps it needs to go
back in.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 deployment options

2007-09-19 Thread Kenneth Gonsalves


On 20-Sep-07, at 8:09 AM, Graham Dumpleton wrote:

> All those warnings about using the same Apache to serve static
> documents as Django are generally totally meaningless to the average
> user. This is because the load on an average Apache site is no where
> near enough for it to be of concern.

one caveat here - if you are running a site on shared hosting with  
soft RAM limit - like the 40 MB webfaction account, then it is wise  
to bypass mod_python for media to avoid those nasty monday morning  
mails about exceeding your limits and upgrading your account. This  
applies to sites of even 5-10 hits a day. Note, I am not criticising  
webfaction - they rock.

-- 

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
-~--~~~~--~~--~--~---



Where can I find the templatetag called "humanize" in Django application components "django-registration "

2007-09-19 Thread beck917
Where can I find the templatetag called "humanize" in Django application
components "django-registration "

When I run the register page,there raise a error "'humanize' is not a valid
tag library: Could not load template library from
django.templatetags.humanize, No module named humanize"

I can't find the templatetags folder under the registration app,where can I
get it??

I download the application components here:
http://code.google.com/p/django-registration/

thx all~

--~--~-~--~~~---~--~~
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 deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 10:28 am, Steve  Potter <[EMAIL PROTECTED]> wrote:
> > Django can be run fine under Apache 1.3 using mod_wsgi.
>
> > The only issue is whether they do really allow you to add additional
> > Apache modules to the installation.
>
> > Graham
>
> This is interesting...  It is possible to install additional modules
> with cpanel, it just makes updating for new releases of Apache a
> little more complicated.
>
> Do you know where I might find any more information about installing
> Django with mod_wsgi?

On the mod_wsgi web site at 'http://www.modwsgi.org'. In particular:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

but you should ensure you look through the introductory material on
configuration first to get a feel in general for how to setup
mod_wsgi.

Graham



--~--~-~--~~~---~--~~
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 deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 12:16 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 20-Sep-07, at 12:23 AM, Steve Potter wrote:
>
> > I'm already quite sure I don't want to install mod_python on the
> > existing Apache after reading all of the warnings about using the same
> > Apache to serve static documents and Django.
>
> I am not sure exactly what you mean by this. mod_python is the
> preferred way to go. The only thing is that static content/media will
> go directly to apache bypassing mod_python. The 'warnings' are only
> to help you to improve performance. Just performance, nothing evil
> will happen if you serve those through mod_python.

All those warnings about using the same Apache to serve static
documents as Django are generally totally meaningless to the average
user. This is because the load on an average Apache site is no where
near enough for it to be of concern. Problem is that people like to
run these benchmarks looking at raw low level performance and because
lighttpd shows better static file performance that it must therefore
be better to farm off the static file requests. Reality is that the
bottle neck for your application is going to be the Python code and
database access. This is going to slow down the user experience
immensely more than how quick your static files are served up.

So, unless you know you are going to be running a web site with huge
numbers of hits a day, it is probably reasonably safe to totally
ignore such warnings. If you are going to run a large site with a lot
of hits, you shouldn't be listening to such hearsay and should instead
be doing your own proper benchmarking with the particular hardware you
intend using. From that you are more likely to look at using multiple
machines and a proper front end distributed load balancing solution
than toying with trying to run lighttpd and Apache together with
Apache proxying static requests to lighttpd. In general it just isn't
going to be worth the effort.

Now I now that some are likely to disagree with this. Well all I can
say is show me the proper analysis and benchmarking that it makes any
difference for your average web site. There may be some anecdotal
comments about this on the net, but finding some real substance to
such claims is much harder to come by.

In summary, go with what is ever the easiest for you to setup and
manage and does what you need. When your web site takes off and looks
like it will become the next greatest thing, then you might revisit
it, but you will go a long way with a simple setup before needing
anything more complicated. In the meantime, concentrate on optimising
your Python application first and reducing its bottlenecks.

Graham


--~--~-~--~~~---~--~~
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: Video Blogging - Django + Flash

2007-09-19 Thread beck917
WOW~~It's so cool...Great tutorial~!~thx~~~

2007/9/20, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
> Here's a good post I saw on vblogging: http://blog.go4teams.com/?p=56
>
> Hope it's helpful,
>
> - Lis
>
>
> >
>

--~--~-~--~~~---~--~~
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 deployment options

2007-09-19 Thread Kenneth Gonsalves


On 20-Sep-07, at 12:23 AM, Steve Potter wrote:

> I'm already quite sure I don't want to install mod_python on the
> existing Apache after reading all of the warnings about using the same
> Apache to serve static documents and Django.

I am not sure exactly what you mean by this. mod_python is the  
preferred way to go. The only thing is that static content/media will  
go directly to apache bypassing mod_python. The 'warnings' are only  
to help you to improve performance. Just performance, nothing evil  
will happen if you serve those through mod_python.

-- 

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
-~--~~~~--~~--~--~---



Video Blogging - Django + Flash

2007-09-19 Thread [EMAIL PROTECTED]

Here's a good post I saw on vblogging: http://blog.go4teams.com/?p=56

Hope it's helpful,

- Lis


--~--~-~--~~~---~--~~
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: RoR vs Django - mac vs pc parody ad

2007-09-19 Thread [EMAIL PROTECTED]

Mike B: I saw that earlier but, obviously, loved it!

On Sep 19, 6:08 pm, "Mike B." <[EMAIL PROTECTED]> wrote:
> RailsEnvy's outrageous 
> parody:http://www.railsenvy.com/2007/9/10/ruby-on-rails-vs-django-commercial-7
>
> Sorry guys, but I couldn't resist...
>
> Cheers,
>
> Mike Blass


--~--~-~--~~~---~--~~
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: Add Support for Hex numbers is Admin

2007-09-19 Thread Kevin

This is great thanks! You were one step ahead of me on the display.
I'm still reading up on customizing the admin interface, but hopefully
something in there will help me adding any javascript if it is needed.

Thanks!

On Sep 19, 3:25 pm, jake elliott <[EMAIL PROTECTED]> wrote:
> hi kevin,
>
> you could convert to int in the model's save() method
>
> class MyModel(models.Model):
> def save(self):
> self.hexval = int(str(self.hexval), 16)
> super(MyModel, self).save()
>
> or whatever hex->decimal method you need for how you have the hex val
> stored.
>
> but then how to get it back into a hex representation when someone goes
> to edit the field?  the only thing that comes to my mind is javascript
> but i'm sure there's a less hackish solution :)
>
> best
> jake
>
> Kevin wrote:
> > In the admin interface if someone enters a number in hex, then it
> > fails the validation test. I've managed to make it pass the validation
> > test, but now the number gets passed in hex to the back-end database
> > (which does not support hex). Any ideas on how I might be able to
> > convert the number to an integer before it hits the database?
>
> > Thanks,
> > Kevin


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Trying to install trunk version - svn error

2007-09-19 Thread [EMAIL PROTECTED]

I'm using django 0.96 / python 2.5.1 / ubuntu 7.04 but I got the 00903
Oracle error and I'm trying to use the trunk version.

I follow the instruction on http://www.djangoproject.com/documentation/install/
But I got:

svn: Requisição REPORT falhou em '/svn/!svn/vcc/default'
svn: REPORT de '/svn/!svn/vcc/default': 400 Bad Request (http://
code.djangoproject.com)

Is this a svn misconfiguration on my machine ? or on the server?
Any suggestion will be welcome.

Josir Gomes


--~--~-~--~~~---~--~~
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: merging multiple-db-support branch with svn trunk checkout

2007-09-19 Thread Russell Keith-Magee

On 9/20/07, Carlos Hanson <[EMAIL PROTECTED]> wrote:
>
> Greetings,
>
> I am using the current svn checkout of the trunk and would like to
> include the multiple-db-support branch.  What is the best way to do
> this?  I will understand if the answer is read the svn manual (it's on
> my list of things to do).

SVN branches are standalone - you don't 'include' the branch, you get
a complete checkout of the branch. So, you're looking for something
like:

> svn co http://code.djangoproject.com/svn/django/branches/multiple-db-support

However, be warned: the multiple-db-support branch is a little bit
stale at the moment. If you search the archives, you will see that Ben
Ford has some patches that brings the branch mostly up to date. I
haven't played with the branch, or Ben's patches, so I can't comment
on the stability of the branch, or the likelyhood that the design
represented by the branch is suitable for eventual inclusion in the
Django trunk.

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: Django deployment options

2007-09-19 Thread Steve Potter


>
> Django can be run fine under Apache 1.3 using mod_wsgi.
>
> The only issue is whether they do really allow you to add additional
> Apache modules to the installation.
>
> Graham

This is interesting...  It is possible to install additional modules
with cpanel, it just makes updating for new releases of Apache a
little more complicated.

Do you know where I might find any more information about installing
Django with mod_wsgi?

Thanks

Steven Potter


--~--~-~--~~~---~--~~
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 deployment options

2007-09-19 Thread Steve Potter


>
> 5. Use a different server.
>
> Unless you are on what cPanel calls the bleeding edge, you're running
> Apache 1.3 which is useless for serving Django. That leaves you with
> either #3 or #4. #3 has issues because cPanel wants to bind Apache to
> all IP addresses. I had issues (though I didn't troubleshoot them
> throuroughly) with changing httpd.conf to only attach to specific IPs.
> #4 is inefficient and a pain to maintain. I'm moving all my Django
> apps to Slicehost because the cPanel setup is so ugly.
>

Cpanel has actually released Apache 2.0 and 2.2 on Current, and will
be following shortly with Release and stable.  So I suspect that there
will be a growing number of requests to integrate Django with a Cpanel
managed server.  I know that Cpanel can cause some problems trying to
bind Apache to all of the IP addresses, but I believe it is possible
to override that behavior.

So if I decide to go with option 4 and install a second http server,
what is the advantage of lighttpd over a second copy of Apache?

Thanks,

Steven Potter




--~--~-~--~~~---~--~~
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: Using unitest or doc test with complex output

2007-09-19 Thread Russell Keith-Magee

On 9/20/07, cesco <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'd like to test a query and the data returned by that query is a list
> containing a list of objects. For example:
> [[, , ..., ]]
>
> If I try testing using unittests I get the following error:
> AssertionError: [[]] != [[]]
> though to me the expected output and the one I get look identical.

Without the exact test, it's difficult to know exactly what is going
wrong; however, there is one possible generic cause of difficulty.

Despite all appearances,  != .
By extension, lists of  won't be equal, either.

 is the output representation of a Django model
object. The thing is, two model objects with that point to the same
database object (i.e., they have the same model and have the same
primary key) _are not equal_. This is because the _wrapper_ objects
are different. [1]

Generally, if you want to check if two object instances are equal,
compare their primary keys; if you want to compare two lists, compare
lists of primary keys: i.e.,

[obj.id for obj in query.all()] = [1,2,3]

> If I try with doc test then I get the problem when the output span
> multiple lines: even though the objects returned are the right ones,
> the expected string and the one I get are different because of
> newlines and this make the test fail.

This is an inherent difficulty with doctests, and it's one of the
reasons you might want to favour using unittest over doctest.

[1] Before you ask, no, we can't just override __eq__ to check for PK
equality - search the archives if you want to know why.

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: Having Django iterate through JSON possible?

2007-09-19 Thread Russell Keith-Magee

On 9/20/07, Richard Dahl <[EMAIL PROTECTED]> wrote:
> I believe that that is a known bug, thought I do not know details and have
> not had any problems myself, as I have never tried to serialize a decimal.

Known to who? I'm not aware of any current Decimal serialization
issues, and a quick search of the ticket database didn't reveal
anything, either.

There were some decimal serialzation issues when 0.96 was released,
but they were fixed long ago, and the test suite includes Decimal (and
Float) serialization..

Can you either:
 - provide an example that demonstrates your problem
 - point at the Django ticket for the serialization issue you describe.

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: Is there a TRIM feature for templates in Django 0.91

2007-09-19 Thread Russell Keith-Magee

On 9/19/07, Frank Peterson <[EMAIL PROTECTED]> wrote:
>
> TRIM would delete any whitespace from the string (tabs, newlines,
> spaces, ...). SPACELESS comes close as it will convert all the
> whitespace into just 1 space.

This behaviour has changed in the SVN version of Django. Now spaceless
will remove all spaces between tags. The documentation for the tag
explains a few other cases where spaces won't be removed.

> I'm not sure SPACELESS doesnt work, maybe because its around the
> variable story.tease?  I cant do anything via python either, I dont
> have permission and I wouldnt know how anyway, all I deal with is
> templates

Unfortunately, I don't think there is much we can do to help, then. If
you can't update Django, and you can't write a custom template, you're
pretty much stuck with the tags 0.91 offers, and spaceless is pretty
much the only tag that does something like you describe.

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
-~--~~~~--~~--~--~---



Check it out:download free,stock information,knowledge base,hot videos,hot games and hot tickets...

2007-09-19 Thread art

Check it out:download free,stock information,knowledge base,hot
videos,hot games and hot tickets...
http://groups.google.com/group/all-good-things/web/very-useful-websites


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



merging multiple-db-support branch with svn trunk checkout

2007-09-19 Thread Carlos Hanson

Greetings,

I am using the current svn checkout of the trunk and would like to
include the multiple-db-support branch.  What is the best way to do
this?  I will understand if the answer is read the svn manual (it's on
my list of things to do).

Thanks.

Carlos Hanson


--~--~-~--~~~---~--~~
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: apache authorization with django

2007-09-19 Thread Graham Dumpleton

On Sep 20, 8:39 am, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
wrote:
> On 9/19/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
>
> > Not properly though.
>
> Indeed -- the auth handler has always been of "works-for-me" quality;
> I don't know nearly enough about Apache to write a proper one. I would
> be thrilled and delighted if someone who did would step forward and
> write something that was actually correct :)

Problem with that is it would only work with mod_python 3.3.1 as older
versions of mod_python do not expose Apache API properly. Even then
there are possibly still some parts of the Apache API not exposed in
mod_python 3.3.1 which will make it harder than it needs to be.

As I flesh out the authorisation bits of mod_wsgi support, then maybe
I'll have a brainwave and come up with something that might also work
on mod_python (to a degree).

Are you going to be happy with something that requires mod_python
3.3.1?

Graham


--~--~-~--~~~---~--~~
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't update my django source via svn

2007-09-19 Thread jake elliott

hi jeff -

django devs are in the process of moving servers so i think this is
probably just a temporary issue.  fwiw i am able to 'svn up' right now
with no problem :|

best,
jake

jeffself wrote:
> I've never run into this problem before but all of a sudden its not
> working.  My source is located in /opt/django_src.  I run 'sudo svn
> update' and I'm now getting errors.
> 
> svn: PROPFIND request failed on '/svn/django/trunk'
> svn: PROPFIND of '/svn/django/trunk': Could not read status line:
> Connection reset by peer.
> 
> Is the repository down right now?
> 
> 
> > 
> 


--~--~-~--~~~---~--~~
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't update my django source via svn

2007-09-19 Thread Jacob Kaplan-Moss

On 9/19/07, jeffself <[EMAIL PROTECTED]> wrote:
>
> I've never run into this problem before but all of a sudden its not
> working.  My source is located in /opt/django_src.  I run 'sudo svn
> update' and I'm now getting errors.
>
> svn: PROPFIND request failed on '/svn/django/trunk'
> svn: PROPFIND of '/svn/django/trunk': Could not read status line:
> Connection reset by peer.
>
> Is the repository down right now?

Seems to work OK to me, and the server isn't throwing any unexpected
errors... perhaps a wonky firewall/proxy on your end?

Jacob

--~--~-~--~~~---~--~~
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't update my django source via svn

2007-09-19 Thread jeffself

I've never run into this problem before but all of a sudden its not
working.  My source is located in /opt/django_src.  I run 'sudo svn
update' and I'm now getting errors.

svn: PROPFIND request failed on '/svn/django/trunk'
svn: PROPFIND of '/svn/django/trunk': Could not read status line:
Connection reset by peer.

Is the repository down right now?


--~--~-~--~~~---~--~~
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: apache authorization with django

2007-09-19 Thread Jacob Kaplan-Moss

On 9/19/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
> Not properly though.

Indeed -- the auth handler has always been of "works-for-me" quality;
I don't know nearly enough about Apache to write a proper one. I would
be thrilled and delighted if someone who did would step forward and
write something that was actually correct :)

Jacob

--~--~-~--~~~---~--~~
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: apache authorization with django

2007-09-19 Thread Graham Dumpleton

On Sep 19, 10:46 pm, Robin Becker <[EMAIL PROTECTED]> wrote:
> Graham Dumpleton wrote:
>
> .
>
> >>> In 2.0 there seems no way to provide another
> >>> authorizer without writing an apache module.
> >> Correct.
>
> > Whoops. Not strictly true. You can write one with mod_python by
> > implementing a authzhandler(). You just need to know what you are
> > doing. ;-)
>
> 
> that's what the django approach is doing :)

Not properly though.

Your Django code is combining both authentication and authorisation
phases into what is the authentication handler. In other words, how it
is doing things is wrong and isn't how things are meant to be done in
Apache. Although your code works with Apache 2.0, you will find that
it probably will not work correctly in Apache 2.2 because of the
tightening up on how authentication/authorisation works. I know Jacob
will concur on this given the issues he had in this area in moving the
main Django site to Apache 2.2. :-)

In short, processing of the Require directive is not meant to be done
in the authentication phase. It is supposed to be done in the
authorisation phase instead. As a result, you will have a bit of fun
battling with Apache 2.2 authorisation phase with that code as is.

Graham


--~--~-~--~~~---~--~~
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 deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 8:03 am, "Peter Baumgartner" <[EMAIL PROTECTED]> wrote:
> On 9/19/07, Steve Potter <[EMAIL PROTECTED]> wrote:
>
> > I currently have a dedicated server running a Cpanel installation with
> > several virtual hosts.   I would like to install Django on this server
> > and as far as I can tell, I have several options.
>
> > 1.  Add mod_python to existing Apache installation
> > 2.  Add FastCGI to existing Apache installation
> > 3.  Install secondary server (another installation of apache lighttpd,
> > etc..) bound to another ip address for Django
> > 4.  Same as above, but instead of a different ip address use localhost
> > and install mod_proxy on existing Apache.
>
> 5. Use a different server.
>
> Unless you are on what cPanel calls the bleeding edge, you're running
> Apache 1.3 which is useless for serving Django.

Django can be run fine under Apache 1.3 using mod_wsgi.

The only issue is whether they do really allow you to add additional
Apache modules to the installation.

Graham


--~--~-~--~~~---~--~~
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: Talk like a Pirate Middleware

2007-09-19 Thread Scott Benjamin

I think I will incorporate his work as it's far more extensive than
the pirate list I used.

On Sep 19, 11:55 pm, Nowell <[EMAIL PROTECTED]> wrote:
> Jacob wrote something like this a while 
> agohttp://toys.jacobian.org/misc/pirate.py.txt
>
> On Sep 19, 5:26 am, Scott Benjamin <[EMAIL PROTECTED]> wrote:
>
> > Today I was looking for some middleware that would allow changing of
> > the text of a site into Pirate Talk  without effecting the content, as
> > today was Talk like a Pirate day.http://www.talklikeapirate.com/.
> > There wasn't anything available for Django that would change site text
> > into "Pirate Talk".
>
> > Being inspired by some conversations on the django IRC channel, I
> > decided to dig into the Middleware and attempt it myself.   After
> > about spending  an hour learning Django Middleware and BeautifulSoup,
> > I've finished the Talk like a Pirate middleware! I wouldn't say it's
> > the best thing since sliced bread but it does work, was a blast to
> > write ;)  Writing middleware was very simple.
>
> > You can find more information at:
>
> >http://www.scott-benjamin.com/blog/2007/sep/19/django-talk-pirate-arr...
>
> > Cheers!
> > Scott


--~--~-~--~~~---~--~~
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: Creating link to root

2007-09-19 Thread havard

Florian Lindner skreiv:
> Hello,
> a common problem I have is that I have references in my main template like CSS
> or an background image:
>
> 
>
> This template is used within different paths. Therefore I need to have the
> styles.css availabe in every path the template could be used.
> An alternative would be give the entire URL href="http://xgm.de/styles.css.
> But then I need to change that line everytime when I deploy my app from
> localhost to a domain.
> Another working solution is to model the regexp in a way that styles.css is
> always available: r"^.*styles\.css$"
> It works but makes caching for browsers impossible and clutters the paths.
> Is there a tag like {% domain %} that gives me the domain and I can construct
> a path like http://xgm.de/styles.css dynamically (and it changes to
> http://localhost:8000/styles.css when I am on localhost)?
> Or how is this problem commonly solved with Django?

I solved this problem in the following way:
1) Set the stylesheet link tag to 
2) Created a rule in urls.py where r"^styles\.css" points to an
appropriately written view.
3) Created a view that output the desired CSS code as plain text
(using a template)

As far as I can see there are several advantages to this way of doing
it. First, the stylesheet becomes available as 
http:///styles.css,
so browsers should have no problem caching it. (By the way, have a
look at http://www.stefanhayden.com/blog/2006/04/03/css-caching-hack/
for a nice hack to ensure CSS caching is only done whenever you want
it to be done.) Second, the full template system of Django becomes
available also for generating CSS, including the nifty template
inheritance feature.

The view in urlconf in 2) and view in 3) could easily be modified to
output different CSS files by letting the urlconf pass the name of the
CSS file as a parameter to the view.

Best,
Håvard


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Using unitest or doc test with complex output

2007-09-19 Thread cesco

Hi,

I'd like to test a query and the data returned by that query is a list
containing a list of objects. For example:
[[, , ..., ]]

If I try testing using unittests I get the following error:
AssertionError: [[]] != [[]]
though to me the expected output and the one I get look identical.

If I try with doc test then I get the problem when the output span
multiple lines: even though the objects returned are the right ones,
the expected string and the one I get are different because of
newlines and this make the test fail.

Is there any solution to this problem (with particular regard to
unittest, which I would prefer to use)?

thanks and regards
Francesco


--~--~-~--~~~---~--~~
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 deployment options

2007-09-19 Thread Peter Baumgartner

On 9/19/07, Steve Potter <[EMAIL PROTECTED]> wrote:
>
> I currently have a dedicated server running a Cpanel installation with
> several virtual hosts.   I would like to install Django on this server
> and as far as I can tell, I have several options.
>
> 1.  Add mod_python to existing Apache installation
> 2.  Add FastCGI to existing Apache installation
> 3.  Install secondary server (another installation of apache lighttpd,
> etc..) bound to another ip address for Django
> 4.  Same as above, but instead of a different ip address use localhost
> and install mod_proxy on existing Apache.
>
5. Use a different server.

Unless you are on what cPanel calls the bleeding edge, you're running
Apache 1.3 which is useless for serving Django. That leaves you with
either #3 or #4. #3 has issues because cPanel wants to bind Apache to
all IP addresses. I had issues (though I didn't troubleshoot them
throuroughly) with changing httpd.conf to only attach to specific IPs.
#4 is inefficient and a pain to maintain. I'm moving all my Django
apps to Slicehost because the cPanel setup is so ugly.

If you do go this route, I'd highly recommend using daemontools to
manage your django FCGI processes. It has served me well. You may also
find this helpful
http://coderseye.com/2007/lighttpd-on-cpanel-vps.html

--~--~-~--~~~---~--~~
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: unsupported operand type(s) for *: 'Decimal' and 'Decimal'

2007-09-19 Thread Jeremy Dunck
On 9/19/07, Landlord Bulfleet <[EMAIL PROTECTED]> wrote:
...
>
> sum is property of a model object in our database
> (models.DecimalField(max_digits=7, decimal_places=2)) & f_c.rate is a
> Decimal constructed using Decimal(string) construction (Decimal is imported
> with "from decimal import Decimal")
>
> We have some doubts that this may be a result of the django's python 2.3
> _decimal compatibility.

You're using PsycoPG with multiple interpreters.  :)

http://www.initd.org/tracker/psycopg/ticket/192
http://groups.google.com/group/django-developers/browse_thread/thread/63046b2fca27673c/898dbf8da327ce71

Anyway, I did run into this using psycopg1, but switched to psycopg2
and patched it since 1) it's being maintained and 2) it was easier to
fix that way.

I emailed the psycopg list a couple weeks ago with a patch but never
heard back from them.  I don't have rights to add the patch to their
ticket tracker, or I'd do that, too.

I'm attaching a patch against psycopg2's source code here.   This is
for r896 on the 2.0.x branch.

Alternatively, you could run separate apache processes for each needed
interpreter or switch to mod_wsgi.

I wasn't prepared to swtich to mod_wsgi in a hurry, so patched
psycopg2 instead.

Apparently not that many people are using multiple interpreters and
decimal fields with psycopg...

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---

Index: psycopg/psycopg.h
===
--- psycopg/psycopg.h	(revision 896)
+++ psycopg/psycopg.h	(working copy)
@@ -129,8 +129,7 @@
 char *pyenc;
 } encodingPair;
 
-/* the Decimal type, used by the DECIMAL typecaster */
-extern PyObject *decimalType;
+extern PyObject *psyco_decimal_type(void);
 
 /* some utility functions */
 extern void psyco_set_error(PyObject *exc, PyObject *curs,  char *msg,
Index: psycopg/psycopgmodule.c
===
--- psycopg/psycopgmodule.c	(revision 896)
+++ psycopg/psycopgmodule.c	(working copy)
@@ -62,7 +62,6 @@
 PyObject *pyPsycopgTzFixedOffsetTimezone = NULL;
 
 PyObject *psycoEncodings = NULL;
-PyObject *decimalType = NULL;
 
 /** connect module-level function **/
 #define psyco_connect_doc \
@@ -330,7 +329,7 @@
 #endif
 
 #ifdef HAVE_DECIMAL
-microprotocols_add((PyTypeObject*)decimalType, NULL, (PyObject*));
+microprotocols_add((PyTypeObject*)psyco_decimal_type(), NULL, (PyObject*));
 #endif
 }
 
@@ -554,27 +553,7 @@
 }
 }
 
-/* psyco_decimal_init
 
-   Initialize the module's pointer to the decimal type. */
-
-void
-psyco_decimal_init(void)
-{
-#ifdef HAVE_DECIMAL
-PyObject *decimal = PyImport_ImportModule("decimal");
-if (decimal) {
-decimalType = PyObject_GetAttrString(decimal, "Decimal");
-}
-else {
-PyErr_Clear();
-decimalType = (PyObject *)_Type;
-Py_INCREF(decimalType);
-}
-#endif
-}
-
-
 /** method table and module initialization **/
 
 static PyMethodDef psycopgMethods[] = {
@@ -730,7 +709,6 @@
 /* other mixed initializations of module-level variables */
 psycoEncodings = PyDict_New();
 psyco_encodings_fill(psycoEncodings);
-psyco_decimal_init();
 
 /* set some module's parameters */
 PyModule_AddStringConstant(module, "__version__", PSYCOPG_VERSION);
Index: psycopg/typecast_basic.c
===
--- psycopg/typecast_basic.c	(revision 896)
+++ psycopg/typecast_basic.c	(working copy)
@@ -113,6 +113,40 @@
 return res;
 }
 
+/* psyco_decimal_type
+
+   Retrieve the decimal type from the current interpreter.
+   Can't cache due to each interpreter having separate sys.modules, 
+ which causes isinstance(Decimal(), Decimal) to fail between interpreters.
+
+   //FIXME: dropping refs every time it's called; dangerous if 
+   //  there are no other references in interp.
+   //We should have a pre-compiler
+   //  WITH_MULTI_INTERPRETER to store typecasters per interpreter.
+*/
+
+PyObject *psyco_decimal_type(void)
+{
+#ifdef HAVE_DECIMAL
+   
+   PyObject *decimal = PyImport_ImportModule("decimal");
+   PyObject *decimalClass;
+   
+   if (decimal) {
+   Py_DECREF(decimal);
+   decimalClass = PyObject_GetAttrString(decimal, "Decimal");
+   Py_DECREF(decimalClass);
+   }
+   else {
+   PyErr_Clear();
+   decimalClass = (PyObject *)_Type;
+   }
+   return decimalClass;
+#endif
+}
+
+
+
 /** DECIMAL - cast any kind of number into a Python Decimal object **/
 
 #ifdef HAVE_DECIMAL
@@ -127,7 +161,7 @@
 if ((buffer = PyMem_Malloc(len+1)) == NULL)
 

Re: fixtures: Invalid model identifier

2007-09-19 Thread johnny

FIX: "model": "category.Category",

NOT this: "model": "apps.category.models.Category",





--~--~-~--~~~---~--~~
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: fixtures: yaml, manage.py syncdb error when no data in initial_data.yml

2007-09-19 Thread johnny

this error is due to auto incremented primary key.  you can't have
empty fixture file.


--~--~-~--~~~---~--~~
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: Add Support for Hex numbers is Admin

2007-09-19 Thread jake elliott

hi kevin,

you could convert to int in the model's save() method

class MyModel(models.Model):
def save(self):
self.hexval = int(str(self.hexval), 16)
super(MyModel, self).save()

or whatever hex->decimal method you need for how you have the hex val
stored.

but then how to get it back into a hex representation when someone goes
to edit the field?  the only thing that comes to my mind is javascript
but i'm sure there's a less hackish solution :)

best
jake

Kevin wrote:
> In the admin interface if someone enters a number in hex, then it
> fails the validation test. I've managed to make it pass the validation
> test, but now the number gets passed in hex to the back-end database
> (which does not support hex). Any ideas on how I might be able to
> convert the number to an integer before it hits the database?
> 
> Thanks,
> Kevin
> 
> 
> > 
> 


--~--~-~--~~~---~--~~
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: Having Django iterate through JSON possible?

2007-09-19 Thread Richard Dahl
I believe that that is a known bug, thought I do not know details and have
not had any problems myself, as I have never tried to serialize a decimal.
-richard


On 9/19/07, robo <[EMAIL PROTECTED]> wrote:
>
>
> Hmm ... I tested these in non-Django templates and Django itself gave
> me no errors. But now that I've tested it on a Django template, it's
> giving me "Decimal("0.00") is not JSON serializable" errors.
>
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django deployment options

2007-09-19 Thread Steve Potter

I currently have a dedicated server running a Cpanel installation with
several virtual hosts.   I would like to install Django on this server
and as far as I can tell, I have several options.

1.  Add mod_python to existing Apache installation
2.  Add FastCGI to existing Apache installation
3.  Install secondary server (another installation of apache lighttpd,
etc..) bound to another ip address for Django
4.  Same as above, but instead of a different ip address use localhost
and install mod_proxy on existing Apache.

I'm already quite sure I don't want to install mod_python on the
existing Apache after reading all of the warnings about using the same
Apache to serve static documents and Django.

I am interested in pros and cons of the different options as well as
any options I may have missed.

I would also like to know what others have tried.

Thanks,

Steven Potter


--~--~-~--~~~---~--~~
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: Having Django iterate through JSON possible?

2007-09-19 Thread Richard Dahl
robo,
I think you may be looking at this the wrong way.  The way I am using JSON
is to pass server generated data from django to my javascript callback on
the client. That is it.  when I make a request from the client to the server
I do things exactly like I would do a "Web 1.0" application.  When you go to
the index page of my app a YUI treeview is created on the left side of the
screen with various component names in the tree.  Clicking on any of the
component names will cause an async request to be made (AJAX) to django at a
url defined within urls.py just as a synchronous request, i.e.
'/add_tree_node/device'.  The difference is that the view that responds to
this url returns an HttpResponse that contains a JSON object instead of
html.  The javascript function processes the JSON object and changes the DOM
to add whatever markup is provided, alert the user, etc...  There is no time
where django needs to iterate through JSON directly.  The template for the
'index' page where this is happening has already been parsed by django and
that action is done.

The 'form' object that is returned is a standard
django.newforms.Formsubclass (or a form_for_model or
form_for_instance) and that template is
used only to essentially create an html snippet that can be displayed via
the javascript callback.  This process happens natively within django with
no JSON at all.  I am using a regular call to a model, i.e. d =
Device.objects.get(pk=1) to get the device object and f =
forms.form_for_instance(d) to get the form.  The render_to_response works
the same way, putting together html just like django always does.  The
JSONification happens with the simplesjson.dumps(response_dict)  and it is
pure javascript on the client callback to munge the returned data.

As far as why you are having problems with serializers I do not know, I have
only used simplejson.dumps.  I believe it is failing with your code because
it expects a  python dictionary, not a django queryset.
Try something like

data = Manager.objects.all()
managers = []
for d in data:
managers.append({'data_attr1': d.attr1, 'data_attr2': d.attr2,
etc.})
response_dict = {'Managers':  data}
return HttpResponse(simplejson.dumps(response_dict), mimetype="application/
javascript")

When you evaluate the JSON object with your javascript, the ouptut should
look like {Manageers:[{'data_attr1': d.attr1, 'data_attr2':
d.attr2},{'data_attr1':
d.attr1, 'data_attr2': d.attr2}]}
so using the YUI you would eval the response.ResponseText and end up with a
response_obj.Managers object that would contain the list of dictionaries.

Does this make sense?

-richard


On 9/19/07, robo <[EMAIL PROTECTED]> wrote:
>
>
> Richard, it still doesn't seem like Django can iterate through json.
> All we can do is stuff data into div tags. In the "{% if form %}"
> statement of yours, is "form" the object that you got from "var myobj
> = response_obj.form;" ? If it is, then you might have something
> special going on there that I can learn from.
>
> But meanwhile, I've tried to switch from serializers to simplejson,
> and it's giving me a "Error: bad http response code:500" everytime,
> whereas serializers give me the same error only 50% of the time (and
> this too is BAD!).
>
> When I'm using serializers, the only difference between getting an
> error not depends on which objects I'm getting. For example, I get an
> error when I use this code:
> def ajax_form_test(request):
>   data = serializers.serialize("json", Order.objects.all())
>   return HttpResponse(data, mimetype="application/javascript")
>
> but no errors when I use this code:
> def ajax_form_test(request):
>   data = serializers.serialize("json", Manager.objects.all())
>   return HttpResponse(data, mimetype="application/javascript")
>
> And when I use simplejson, I ALWAYS get errors no matter what. The
> code is as simple as this:
> def ajax_form_test(request):
>   data = Manager.objects.all()
>   return HttpResponse(simplejson.dumps(data), mimetype="application/
> javascript")
>
> Help me solve this bizzare mystery!
>
> Thanks,
>
> robo
>
>
> >
>

--~--~-~--~~~---~--~~
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: Having Django iterate through JSON possible?

2007-09-19 Thread robo

Richard, it still doesn't seem like Django can iterate through json.
All we can do is stuff data into div tags. In the "{% if form %}"
statement of yours, is "form" the object that you got from "var myobj
= response_obj.form;" ? If it is, then you might have something
special going on there that I can learn from.

But meanwhile, I've tried to switch from serializers to simplejson,
and it's giving me a "Error: bad http response code:500" everytime,
whereas serializers give me the same error only 50% of the time (and
this too is BAD!).

When I'm using serializers, the only difference between getting an
error not depends on which objects I'm getting. For example, I get an
error when I use this code:
def ajax_form_test(request):
  data = serializers.serialize("json", Order.objects.all())
  return HttpResponse(data, mimetype="application/javascript")

but no errors when I use this code:
def ajax_form_test(request):
  data = serializers.serialize("json", Manager.objects.all())
  return HttpResponse(data, mimetype="application/javascript")

And when I use simplejson, I ALWAYS get errors no matter what. The
code is as simple as this:
def ajax_form_test(request):
  data = Manager.objects.all()
  return HttpResponse(simplejson.dumps(data), mimetype="application/
javascript")

Help me solve this bizzare mystery!

Thanks,

robo


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Add Support for Hex numbers is Admin

2007-09-19 Thread Kevin

In the admin interface if someone enters a number in hex, then it
fails the validation test. I've managed to make it pass the validation
test, but now the number gets passed in hex to the back-end database
(which does not support hex). Any ideas on how I might be able to
convert the number to an integer before it hits the database?

Thanks,
Kevin


--~--~-~--~~~---~--~~
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: TypeError: str() takes at most 1 argument (4 given)

2007-09-19 Thread Joe Holloway

On 9/19/07, Joe Holloway <[EMAIL PROTECTED]> wrote:
> On 9/19/07, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
> >
> > On 9/19/07, Joe Holloway <[EMAIL PROTECTED]> wrote:
> > > Anyone give me a nudge in the right direction?
> >
> > Posting the model you're working with is gonna help quite a bit.
> > Chances are you've got something wrong there.
>
> You are right.  By process of elimination I was able to reduce my
> model to this and still recreate the error:
>
> class Organization(models.Model):
> organization_id = models.IntegerField(primary_key=True)
> services = models.CharField()
> class Meta:
> db_table = u'tm_organization'
>
> The problem appears to be with the 'services' field.  I speculated
> that 'services' may be reserved somewhere so I changed it to this:
>
> my_field = models.CharField (db_column='services')
>
> The same error resulted, so now I'm thinking that something doesn't
> like there being a column named 'services'.
>
> Does that make sense?
>

Nevermind.  I looked a little closer at the table and this column is
not a varchar, rather it's declared as a 'set'.  I think that is
probably the root cause, but I'm still not sure why it results in the
trace above.

--~--~-~--~~~---~--~~
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: TypeError: str() takes at most 1 argument (4 given)

2007-09-19 Thread Joe Holloway

On 9/19/07, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On 9/19/07, Joe Holloway <[EMAIL PROTECTED]> wrote:
> > Anyone give me a nudge in the right direction?
>
> Posting the model you're working with is gonna help quite a bit.
> Chances are you've got something wrong there.

You are right.  By process of elimination I was able to reduce my
model to this and still recreate the error:

class Organization(models.Model):
organization_id = models.IntegerField(primary_key=True)
services = models.CharField()
class Meta:
db_table = u'tm_organization'

The problem appears to be with the 'services' field.  I speculated
that 'services' may be reserved somewhere so I changed it to this:

my_field = models.CharField (db_column='services')

The same error resulted, so now I'm thinking that something doesn't
like there being a column named 'services'.

Does that make sense?

--~--~-~--~~~---~--~~
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: manage.py dumpdata && loaddata -- problem with datetime fields

2007-09-19 Thread Tomasz Melcer

On 19 Wrz, 16:37, Rob J Goedman <[EMAIL PROTECTED]> wrote:
> Tomasz,
>
> The fixture is breaking with ' "2007-09-17 09:17:57.890755", ', after
> revision 6329 it either
> started to add the subseconds or can't read them anymore. Not sure if
> there are more instances
> of such a time format. Remove the .nn part to fix it.
>
> I've been running on r6329 for several days now and that seems to
> work fine. Haven't tried
> todays version yet.
>
> Regards,
> Rob
I've got the bug even with 6329. I don't know why, possibly because of
using sqlite, and you wrote you're using postgresql. I guess there is
datetime object converted to string using simple str() or unicode()
call instead of using strftime, but see bunch of strftimes in django
code, so I'm not sure. I know str() adds microseconds to string
representation when nonzero...

Also some databases don't store microseconds, so str() will think
microseconds==0 and will not add them, making json correct. That might
be the difference between sqlite and postgres (i don't know the
latter).

Also I noticed that xml format is working well. That probably means
xml doesn't use str() (if my hypothesis is correct). I haven't got
much time for investigation though.


--~--~-~--~~~---~--~~
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: Is there a TRIM feature for templates in Django 0.91

2007-09-19 Thread Tim Chase

> TRIM would delete any whitespace from the string (tabs, newlines,
> spaces, ...). SPACELESS comes close as it will convert all the
> whitespace into just 1 space.

Should TRIM delete *all* whitespace, or just leading/trailing 
whitespace?  Trim functions usually just remove leading/trailing 
whitespace.

> {% block data %}{% spaceless %}{{ story.tease }}{% endspaceless %}
> {%endblock %}

You may be able to get away with simply using

   {{ story.tease.strip }}

If you need to remove *all* whitespace, not just the 
leading/trailing whitespace, you'll have to create your own 
filter to do it.  However, it's a fairly simple filter process:


import re
from django.template.defaultfilters import stringfilter
from django import template
register = template.Library()
whitespace_re = re.compile(r'\s')

@register.filter(name='remove_whitespace')
@stringfilter
def remove_whitespace(s):
 return whitespace_re.sub('', s)


If the above "{{ story.tease.strip }}" doesn't work for some 
reason (because "tease" is an object rather than a string, most 
likely), you can create a filter out of it the same way, only using

@register.filter(name='strip')
@stringfilter
def strip(s):
 return s.strip()

Either of these should then be usable as

   {{ story.tease|strip }}
or
   {{ story.tease|remove_whitespace }}

You can learn all about creating custom filters at

http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters

-tim





--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



TemplateSyntaxError after svn-updating

2007-09-19 Thread Filipe Correia

Hello,

I've svn updated my working copy of django and started getting the
following error:

TemplateSyntaxError at /
Template u'../common/searchForm.html' cannot be extended, because it
doesn't exist


This is happening while processing another template, ie:
/myproj/templates/specific/searchForm.html

where i use template inheritance with:
{% extends "../common/searchForm.html" %}

Do relative paths no longer work with the current version of django?
might it be a bug or some misuse on my part?

thanks,
Filipe


--~--~-~--~~~---~--~~
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: Adding a custom admin view to the admin app listing

2007-09-19 Thread Christopher Allan Webber

Sure, we can do this, but this doesn't provide a nice
application-level way of adding this to the admin listing.

At the company I work for, we have over 100 websites we deploy for
(and we are just starting to transition to Django).  We deploy each
application individually depending on a client's need... X client may
need a survey tool, a news tool, and so on.  We install them as they
purchase them from us.  We have a very automated way of deploying
things, and to have to add this functionality to the admin's index
template for each application every time we deploy the application is
going to become a nightmare.

I'm actually working on a ticket related to the newforms admin, though
I've only made a small amount of progress so far (this has been the
week from hell at work):
http://code.djangoproject.com/ticket/2292

And yes, it's pretty obvious from the work I've done so far that there
doesn't seem to be a nice way to do this that's built in.  I was
hoping there was some other clean workaround, but I guess that's a bit
silly.

Maybe my work on the current ticket will give me enough experience so
that I can suggest a nice, official way to get admin actions (that
aren't just adding, updating, or deleting data in a model) listed in
the admin interface.  It's definetly going to be a critical need for
our company.

olivier <[EMAIL PROTECTED]> writes:

> Hi,
>
>> But I want it to be listed along with the rest of the admin listing
>> for that app.
>
>
> I may not have understood what you have in mind, but why don't you add
> something after the line 39 of contrib/admin/templates/index.html (or
> actually your copy of it):
>
> {% for model in app.models %}
>   ... regular admin stuff
> {% endfor %}
> 
>  upload CSV file 
>
> Olivier
>
>
> 

--~--~-~--~~~---~--~~
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: python script

2007-09-19 Thread Xan

Yes, I refering to that.
Many thanks,
Xan.

PS: There is a ticket for that, that "officially" say that you
say. ;-)
http://code.djangoproject.com/ticket/5534

On Sep 18, 8:27 pm, Horst Gutmann <[EMAIL PROTECTED]> wrote:
> You mean an error telling you that you need to set the
> DJANGO_SETTINGS_MODULE environment variable? Or something else?
>
> os.environ['DJANGO_SETTINGS_MODULE']='mysite.settings'
>
> right at the top of your script (after the #! and the import for os ;) )
> should solve this.
>
> Then you should probably also add the parent directory of your project
> to sys.path :-)
>
> - Horst
>
> Xan wrote:
> > Hi,
>
> > If we have the models models.py:
>
> > from django.db import models
>
> > class Poll(models.Model):
> > question = models.CharField(max_length=200)
> > pub_date = models.DateTimeField('date published')
>
> > class Choice(models.Model):
> > poll = models.ForeignKey(Poll)
> > choice = models.CharField(max_length=200)
> > votes = models.IntegerField()
>
> > [example extracted 
> > frohttp://www.djangoproject.com/documentation/tutorial01/]
>
> > how can I write a python script for create various polls?
>
> > I tried:
>
> > a.py:
>
> > #!/usr/bin/python
> > from mysite.polls.models import Poll
> > import datetime
>
> > i = 0
> > while i<4:
> > a = str(i)
> > print a
> > Poll.create(question=a, data=datetime.date.today())
> > i = i+1
>
> > but when I run python a.py in bash, there are problems with imports.
> > What lines of imports we need for running a standalone python script?
>
> > Thanks in advance,
> > Xan.
>
> > PS: There is no doc in official site mentioning that. Maybe good to
> > add it to 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
-~--~~~~--~~--~--~---



Re: TypeError: str() takes at most 1 argument (4 given)

2007-09-19 Thread Jacob Kaplan-Moss

On 9/19/07, Joe Holloway <[EMAIL PROTECTED]> wrote:
> Anyone give me a nudge in the right direction?

Posting the model you're working with is gonna help quite a bit.
Chances are you've got something wrong there.

Jacob

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



TypeError: str() takes at most 1 argument (4 given)

2007-09-19 Thread Joe Holloway

I'm a little stumped on this one, though admittedly I'm still learning
to read python stacktraces so it could be something obvious to the
trained eye.

This happens with the latest development version of Django and also
with 0.96.   I have an existing MySQL database and I used 'inspectdb'
to reverse engineer a Django model from it (using MySqlDB 1.2.1-p2).
I cut out everything except for a single table and I'm trying to just
dump everything in the table.

a = Organization.objects.all ()
print a

This produces the following trace:

Traceback (most recent call last):
  File "", line 1, in 
  File "/home/joe/code/repo//lib/python/django/db/models/query.py",
line 108, in __repr__
return repr(self._get_data())
  File "/home/joe/code/repo//lib/python/django/db/models/query.py",
line 482, in _get_data
self._result_cache = list(self.iterator())
  File "/home/joe/code/repo//lib/python/django/db/models/query.py",
line 189, in iterator
cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "")
+ ",".join(select) + sql, params)
  File "/home/joe/code/repo//lib/python/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
  File "/usr/lib/python2.5/site-packages/MySQLdb/cursors.py", line
159, in execute
self.errorhandler(self, TypeError, m)
  File "/usr/lib/python2.5/site-packages/MySQLdb/connections.py", line
35, in defaulterrorhandler
raise errorclass, errorvalue
TypeError: str() takes at most 1 argument (4 given)

I can execute other queries against this model, for example, selecting
with a known key.  I walked through the code, but I couldn't
immediately see where there was a string conversion taking place that
could result in this error.  I'm wondering if this is happening in
native code backing mysqldb?

Anyone give me a nudge in the right direction?

Thanks,
Joe

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



overwriting DEFAULT_DATETIME_INPUT_FORMATS in settings.py raises AttributeError in rev 6368

2007-09-19 Thread olivier

Hi all,

I used to overwrite DEFAULT_DATETIME_INPUT_FORMATS in my settings.py,
to allow for french date formats.
It used to work perfectly, but since rev 6368, it raises a exception.
Anyone knows what's going on ?

Regards,
Olivier

settings.py:

import django.newforms.fields
django.newforms.fields.DEFAULT_DATE_INPUT_FORMATS = ('%d/%m/%Y', '%Y/
%m/%d')



traceback:
===
Traceback (most recent call last):
  File "D:\Code\manage.py", line 4, in 
import settings # Assumed to be in the same directory.
  File "D:\Code\settings.py", line 23, in 
import django.newforms.fields
  File "D:\Lib\django\newforms\__init__.py", line 15, in 
from fields import *
  File "D:\Lib\django\newforms\fields.py", line 347, in 
URL_VALIDATOR_USER_AGENT = settings.URL_VALIDATOR_USER_AGENT
  File "D:\Lib\django\conf\__init__.py", line 28, in __getattr__
self._import_settings()
  File "D:\Lib\django\conf\__init__.py", line 57, in _import_settings
self._target = Settings(settings_module)
  File "D:\Lib\django\conf\__init__.py", line 83, in __init__
mod = __import__(self.SETTINGS_MODULE, {}, {}, [''])
  File "D:\Code\settings.py", line 24, in 
django.newforms.fields.DEFAULT_DATE_INPUT_FORMATS = (DATE_FORMAT,
TABLE_DATE_FORMAT)
AttributeError: 'module' object has no attribute 'newforms'


--~--~-~--~~~---~--~~
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: Trying to use order_by on a list object

2007-09-19 Thread Greg

Tim,
Here is my Price class

class Price(models.Model):
name = models.DecimalField(max_digits=6, decimal_places=2)
price_cat = models.ForeignKey(PriceCategory)

def __str__(self,):
return str(self.name)

class Admin:
pass

//

I guess my 'return str(self.name)' is why my order_by is not working
correctly.  I changed my code to

def __str__(self,):
return self.name

However, now I get the following error when I try to access the my
page that shows all the choice combinations

'TypeError: coercing to Unicode: need string or buffer, float found'

//

Any Suggestions?

Thanks



On Sep 19, 10:20 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I guess the order_by('price') is working.  However, it's not
> > working how I want it to.  When I do the order_by on price
> > django think that a price of 59.99 is greater than a price of
> > 129.99.  I guess it's looking at the first character and since
> > a 1 is less than a 5 it puts the 129.99 price first.  Does
> > anybody know what I need to change to get it so that Django
> > compares prices instead of strings in my price field?
>
> Your guess is correct...CharFields sort character-by-character.
>
> Sounds like your price field should be a DecimalField (or a
> FloatField, depending on whether your version of Django has the
> newly-added DecimalField) rather than a CharField
>
> -tim


--~--~-~--~~~---~--~~
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: Adding a custom admin view to the admin app listing

2007-09-19 Thread olivier

Hi,

> But I want it to be listed along with the rest of the admin listing
> for that app.


I may not have understood what you have in mind, but why don't you add
something after the line 39 of contrib/admin/templates/index.html (or
actually your copy of it):

{% for model in app.models %}
  ... regular admin stuff
{% endfor %}

 upload CSV file 

Olivier


--~--~-~--~~~---~--~~
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: Trying to use order_by on a list object

2007-09-19 Thread Tim Chase

> I guess the order_by('price') is working.  However, it's not
> working how I want it to.  When I do the order_by on price
> django think that a price of 59.99 is greater than a price of
> 129.99.  I guess it's looking at the first character and since
> a 1 is less than a 5 it puts the 129.99 price first.  Does
> anybody know what I need to change to get it so that Django
> compares prices instead of strings in my price field?

Your guess is correct...CharFields sort character-by-character.

Sounds like your price field should be a DecimalField (or a
FloatField, depending on whether your version of Django has the
newly-added DecimalField) rather than a CharField

-tim




--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



fixtures: yaml, manage.py syncdb error when no data in initial_data.yml

2007-09-19 Thread johnny

class Category(models.Model):
id = models.AutoField(primary_key=True)
parent_id = models.IntegerField()
name = models.CharField(maxlength=200)

Problem installing fixture 'c:\mysite\apps\category\fixtures
\initial_data.yaml': 'NoneType' object has no attribute 'anchor'

What is the issue here?  I can't have a empty fixture file?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Adding a custom admin view to the admin app listing

2007-09-19 Thread Christopher Allan Webber

Hello,

For a project we're working on, we need a custom view that's available
only to administrators.  It's not the traditional add/edit/delete
stuff, and the generic admin interface doesn't cut it.  That's fine, I
can write my own view.  (They need to upload a CSV file, which adds
and updates some rows in the database.)

But I want it to be listed along with the rest of the admin listing
for that app.  Like this:

++
|AppName |
++
|Model1  +add /change|
++
|Model2  +add /change|
++
|Upload CSV file | <- add this row
++

See what I mean?  Is this possible?  I can't seem to figure this one
out.

--~--~-~--~~~---~--~~
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: Trying to use order_by on a list object

2007-09-19 Thread Greg

I guess the order_by('price') is working.  However, it's not working
how I want it to.  When I do the order_by on price django think that a
price of 59.99 is greater than a price of 129.99.  I guess it's
looking at the first character and since a 1 is less than a 5 it puts
the 129.99 price first.  Does anybody know what I need to change to
get it so that Django compares prices instead of strings in my price
field?

Thanks

On Sep 19, 12:04 am, Greg <[EMAIL PROTECTED]> wrote:
> Hello,
> I have the following code 's2 = s.sandp.all()'  When I do a 'assert
> False, s2' I get the following:
>
> [, )>,  7'6>, )>, ,  449.99>)>, , )>]
>
> I want to be able to sort the list by the Price.
>
> ///
>
> I tried the following code
>
> s2 = s.sandp.order_by('price')
> assert False, s2
>
> And this is what I get:
>
> [, )>,  7'6>, )>, ,  449.99>)>, , )>]
>
> Notice the last element has a price of 59.99.  Is there anyway that I
> can sort the list so that it's ordered by price?
>
> 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: Is there a TRIM feature for templates in Django 0.91

2007-09-19 Thread Frank Peterson

TRIM would delete any whitespace from the string (tabs, newlines,
spaces, ...). SPACELESS comes close as it will convert all the
whitespace into just 1 space.

I'm stuck on 0.91 at work and I dont think they plan on upgrading
anytime soon (its beyond my control)

I'm not sure SPACELESS doesnt work, maybe because its around the
variable story.tease?  I cant do anything via python either, I dont
have permission and I wouldnt know how anyway, all I deal with is
templates

{% block data %}{% spaceless %}{{ story.tease }}{% endspaceless %}
{%endblock %}


--~--~-~--~~~---~--~~
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: null ForeignKey and INNER JOIN

2007-09-19 Thread olivier

Hi,

> > Is there a way to switch django's relationship building from INNER
> > JOIN to LEFT OUTER JOIN ?
> > It causes unexpected behaviour when filtering on both parent and child
> > tables.
>
> Not really. There is a limited ability to control the join behaviour
> with Q objects, but this isn't documented, and isn't particularly
> robust.


OK. That's bad news, and keep up for the queryset refactor ;o)

For those interested, here is how I'll fix my problem.

class Book(Model)
  title = CharField()
  collection = ForeignKey(Collection)
 def quicksearch(self):
  """returns a list of fields I want to lookup.
  Instead of relying on joins, i'll filter on
  search term in quicksearch."""
  output = []
  for x in (self.title, getattr(self.collection, 'title',
None), etc ):
  output.append(x)
return output


--~--~-~--~~~---~--~~
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: manage.py dumpdata && loaddata -- problem with datetime fields

2007-09-19 Thread Tomasz Melcer

On 17 Wrz, 16:57, Tomasz Melcer <[EMAIL PROTECTED]> wrote:
> On 17 Wrz, 16:45, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:> Perhaps I wasn't clear - I need the actual _data_ - that is, your
> > model, and a fixture file that can't load. I know how to load a
> > fixture - what I don't know is what fixture contents will make a
> > fixture fail in the way you describe.
>
> The fixture:http://dpaste.com/hold/19856/
> I haven't defined any custom models, and the only apps enabled in
> settings.py are auth and contenttypes.
Downgrading to r6263 fixes the problem, r6264 (http://
code.djangoproject.com/changeset/6264/) breaks. Switching to xml
format instead of json also works.


--~--~-~--~~~---~--~~
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: unknown encoding cp0

2007-09-19 Thread Benedict Verheyen

Nis Jørgensen schreef:


>>   
> What is "self" referring to? Can you give us a stack trace? And which
> version of Django are you running (it is especially important to know if
> it is before or after the unicode branch got merged).
> 
> Nis

self is referring to an object that i made to construct automatic 
passwords to manage user creation.

class UserCreation(object):
...

As for the problem, it happens on both my Vista & Windows 2000
I use Python 2.5.1, Apache 2.2.4, mod_python 3.3.1,
Django svn version 6373

= Small trace ==
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in 
_real_get_response
   81. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\lib\site-packages\django\contrib\auth\decorators.py" 
in _checklogin
   17. return view_func(request, *args, **kwargs)
File "E:\Sites\sitesdjango\user_creation\main\views.py" in user_creatie
   50. u.create_all()
File "E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py" 
in create_all
   48. self.report()
File "E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py" 
in report
   329. print "Paswoord: %s " % self.paswoord

   LookupError at /user_creatie/
   unknown encoding: cp0
= Small trace ==

The full trace from Vista (same on Windows2000, identical setup):

 Trace 
LookupError at /user_creatie/
unknown encoding: cp0
Request Method: POST
Request URL:http://user_creation/user_creatie/
Exception Type: LookupError
Exception Value:unknown encoding: cp0
Exception Location: 
E:\Sites\sitesdjango\user_creation\packages\user\user_creation.py in 
report, line 329
Python Executable:  C:\Program Files\Apache Software 
Foundation\Apache2.2\bin\httpd.exe
Python Version: 2.5.1
Traceback (innermost last)
Switch to copy-and-paste view

 * C:\Python25\lib\site-packages\django\core\handlers\base.py in 
_real_get_response
 74. # Apply view middleware
 75. for middleware_method in self._view_middleware:
 76. response = middleware_method(request, callback, 
callback_args, callback_kwargs)
 77. if response:
 78. return response
 79.
 80. try:
 81. response = callback(request, *callback_args, 
**callback_kwargs) ...
 82. except Exception, e:
 83. # If the view raised an exception, run it through exception
 84. # middleware, and if the exception middleware returns a
 85. # response, use that. Otherwise, reraise the exception.
 86. for middleware_method in self._exception_middleware:
 87. response = middleware_method(request, e)
   ▶ Local vars
   Variable Value
   callback 
   
   callback_args
   ()
   callback_kwargs  
   {}
   debug
   
   e
   LookupError('unknown encoding: cp0',)
   exceptions   
   
   mail_admins  
   
   middleware_method
   >
   request  
   , 
POST:, COOKIES:{'sessionid': 
'16b11f2e2176ac612ac40ff5bc79c034'}, META:{'AUTH_TYPE': None, 
'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE': 
'CGI/1.1', 'HTTP_ACCEPT': 
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
 
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 
'nl-be,nl;q=0.8,en;q=0.6,en-us;q=0.4,fr-be;q=0.2', 'HTTP_CONNECTION': 
'keep-alive', 'HTTP_CONTENT_LENGTH': '154', 'HTTP_CONTENT_TYPE': 
'application/x-www-form-urlencoded', 'HTTP_COOKIE': 
'sessionid=16b11f2e2176ac612ac40ff5bc79c034', 'HTTP_HOST': 
'user_creation', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 
'http://user_creation/user_creatie/', 'HTTP_USER_AGENT': 'Mozilla/5.0 
(Windows; U; Windows NT 6.0; nl; rv:1.8.1.6) Gecko/20070725 
Firefox/2.0.0.6', 'PATH_INFO': '/', 'PATH_TRANSLATED': None, 
'QUERY_STRING': None, 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': None, 
'REMOTE_IDENT': None, 'REMOTE_USER': None, 'REQUEST_METHOD': 'POST', 
'SCRIPT_NAME': None, 'SERVER_NAME': 'user_creation', 'SERVER_PORT': 0, 
'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
   resolver 
   
   response 
   None
   self 
   
   settings 
   
   urlconf  
   u'user_creation.urls'
   urlresolvers 
   
 * C:\Python25\lib\site-packages\django\contrib\auth\decorators.py 
in _checklogin
 10. """
 11. if not login_url:
 12. from django.conf import settings
 13. login_url = settings.LOGIN_URL
 14. def _dec(view_func):
 15. def _checklogin(request, *args, **kwargs):
 16. if test_func(request.user):
 17. return 

Re: Hi,what's wrong with the runserver

2007-09-19 Thread Ramiro Morales

On 9/19/07, Hannus <[EMAIL PROTECTED]> wrote:
>
> Hi,guys
> After input the "manage.py runserver" ,there is the following
> errors,what's wrong?The process of installation was always followed
> the documents.My OS is winxp sp2,python is2.51.
> --- 
> -
> Traceback (most recent call last):
> File"D:\python25\lib\site-packages\django\bin\newsite\manage.py",line
> 11,in 
> File"D:\python25\lib\site-packages\django\core
> \managemet.py",line1657,in execute_manager
> project_directory=setup-environ
> File"D:\python25\lib\site-packages\django\core
> \managemet.py",line1649,in setup_environ
> project_module=_import_,<>,['']>
> import error:no module named mysite

Hmm a few strange things:

* managemet.py does not exist on django
* The error is about a "mysite" project but above
  thre is a \newsite\manage.py asi if the name of the
  project were "newsite"

Are you sure that backtrace is a copy paste  from the real one?

Also, it seems you are creating your project inside the bin subdir
of Django. Try creating it on another place of the file system.

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
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 and Twitter

2007-09-19 Thread Tim Chase

> Thanks for taking a look. Still feeling my way on what I need to post
> to be most helpful.

I'd say you did correctly, describing the problem and not 
flooding the list with 20 diff. config files and code...if the 
list needs more info, we usually ask for it :)  However, for 
future reference, full tracebacks (redacted for volumnous or 
confidential data) and exact error messages can be helpful.

The OS/shell info was to ensure that for some reason your 
os.getlogin() call wasn't borked for some reason.

> File "/home/mwaite/django-projects/data/app/models.py" in save
>   170. api = twitter.Api()

it looks like the problem resides here.  From what I see (not 
knowing anything about the twitter API, this answer may register 
a 10 on the bogosity meter), it looks like you're instantiating 
the Api() object with no parameters, and then on your following 
line, throwing away your previous instance ("api") and then 
*re*-instantiating it with parameters.

api = twitter.Api()
api = twitter.Api(username='username',password='password')
status = api.PostUpdate('My update message here')

It seems as though the twitter API is kind enough to try and find 
your username via shell variable and system calls if you don't 
pass it in, but it chokes on something.  As far as I can tell, 
you can simply delete the first line.

> The twitter._GetUsername() doesn't work however:
> 
 >>> twitter._GetUsername()
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'module' object has no attribute '_GetUsername'

It failed because, not surprisingly, the "twitter" module doesn't 
have "_GetUsername".  The above traceback indicates that it 
should be the Api() object that likely has the _GetUsername 
method.  Thus, from a raw python prompt, I'd try just what you 
intend to do in code:

   >>> import twitter
   >>> t = twitter.Api(username='username', password='password')
   >>> status = t.PostUpdate('Testing from python shell')
   >>> print status

to ensure it works as expected, and then, if curious, you can try

   >>> print t._GetUsername()

> I'm not sure what user the python process is running as. It's 
> a local install, running on Apache/ mod_python so I'm guessing
> that it's running as me. Tell me how I can figure it out and
> I'll tell you for sure.

usually in this setup, apache runs as a web-user, usually 
something like "www", "www-data", "_www", or "apache".  However, 
for the time being, I'd say this issue is semi-moot.

-tim





--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Hi,what's wrong with the runserver

2007-09-19 Thread Hannus

Hi,guys
After input the "manage.py runserver" ,there is the following
errors,what's wrong?The process of installation was always followed
the documents.My OS is winxp sp2,python is2.51.
--- 
-
Traceback (most recent call last):
File"D:\python25\lib\site-packages\django\bin\newsite\manage.py",line
11,in 
File"D:\python25\lib\site-packages\django\core
\managemet.py",line1657,in execute_manager
project_directory=setup-environ
File"D:\python25\lib\site-packages\django\core
\managemet.py",line1649,in setup_environ
project_module=_import_,<>,['']>
import error:no module named mysite
--- 
--
Thank you very much

kind regards
Han


--~--~-~--~~~---~--~~
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: apache authorization with django

2007-09-19 Thread Graham Dumpleton



On Sep 19, 10:18 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> > OK my code looks like the standard django/contrib/auth/modpython.py the 
> > patch is
>
> > ***
> > *** 39,44 
> > --- 38,54 
>
> ># check the password and any permission given
> >if user.check_password(req.get_basic_auth_pw()):
> > + G = []  #find required groups
> > + S = filter(None,map(str.split,map(str.strip,req.requires(
> > + map(G.extend,[filter(None,s[1:])
> > + for s in S if s[0].lower()=='group'])
> > + for g in user.groups.all():
> > + if g.name in G:
> > + G.remove(g.name)
> > +
> > + if G:   #fail if required groups remain
> > + return apache.HTTP_UNAUTHORIZED
> > +
> >if permission_name:
> >if user.has_perm(permission_name):
> >return apache.OK
>
> > we're using this kind of phrase in our 2.0 apache configs
>
> > AuthType basic
> > AuthName "djauth test"
> > Require valid-user
> > Require group rptlab
> > #AuthUserFile /home/rptlab/etc/passwd
> > #AuthGroupFile /home/rptlab/etc/groups
> > PythonInterpreter djauth
> > PythonAuthenHandler djauth.modpython
>
> > I'm guessing that AuthBasicProvider (in your examples) is new in Apache 2.2 
> > and
> > makes things easier for this.
>
> Correct.
>
> > In 2.0 there seems no way to provide another
> > authorizer without writing an apache module.
>
> Correct.

Whoops. Not strictly true. You can write one with mod_python by
implementing a authzhandler(). You just need to know what you are
doing. ;-)

Graham


--~--~-~--~~~---~--~~
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: help with fixtures

2007-09-19 Thread Peter Klein

Hi Alex,

I had the same problem and it almost drove me crazy. I even changed
from MySQL to PostgreSQL to rule out the MySQL-DB constraints issue.

But the solution was far more simple: the command 'syncdb' already
populates some tables, e.g. django_content_types and loaddata
therefore tries to update the rows and throws 'duplicate key'-errors.

Make sure you truncate all tables before 'loaddata' and you'll be
fine.

Greetings,
Peter



On 23 Aug., 21:15, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have quite complex application and want to make test suite for it.
> Since its complex, I need some data being populated first, so trying
> to find out how to make fixtures working.
>
> I think I am doing something absolutely wrong way. Since yesterday
> trying to make fixtures working and get one problem after another.
>
> To isolate problems, I've created a very simple model:
>
> class People(models.Model):
> first_name = models.CharField(maxlength=100)
> last_name = models.CharField(maxlength=100)
>
> class Admin:
> pass
>
> and added a few persons.
>
> Then, I am have exported data in all various formats, with hope that
> one of them would work:
>
> ./manage.py dumpdata --format=python > data.python
> ./manage.py dumpdata --format=json > [EMAIL PROTECTED] ./manage.py
> dumpdata --format=xml > data.xml
>
> Now, trying to load it:
>
> 
> "json" fixture format loading produces this = error:
> [EMAIL PROTECTED] ~/tmp/fixture_troubles/FixtureTroubles $ ./manage.pyloaddata
> data.json
> Loading 'data' fixtures...
> Installing json fixture 'data' from absolute path.
> Problem installing fixture 'data.json': duplicate keyviolatesunique
> constraint "django_content_type_app_label_key"
> 
> "python" fixture format produces this error:
> [EMAIL PROTECTED] ~/tmp/fixture_troubles/FixtureTroubles $ ./manage.pyloaddata
> data.python
> Loading 'data' fixtures...
> Installing python fixture 'data' from absolute path.
> Problem installing fixture 'data.python': string indices must be
> integers
> [EMAIL PROTECTED] ~/tmp/fixture_troubles/FixtureTroubles $
> 
> xml fixture format produces this error:
> [EMAIL PROTECTED] ~/tmp/fixture_troubles/FixtureTroubles $ ./manage.pyloaddata
> data.xml
> Loading 'data' fixtures...
> Installing xml fixture 'data' from absolute path.
> Problem installing fixture 'data.xml': duplicate keyviolatesunique
> constraint "django_content_type_app_label_key"
>
> [EMAIL PROTECTED] ~/tmp/fixture_troubles/FixtureTroubles $
>
> Every time I when I am installing fixture I do:
> 1. Drop old database (dropdb fixtures)
> 2. createdb fixtures
> 3. ./manage.py syncdb
>
> and only then, I am attempting to load data.
>
> What I am doing 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
-~--~~~~--~~--~--~---



Re: apache authorization with django

2007-09-19 Thread Graham Dumpleton

On Sep 19, 10:05 pm, Robin Becker <[EMAIL PROTECTED]> wrote:
> Graham Dumpleton wrote:
> > On Sep 19, 3:05 am, Robin Becker <[EMAIL PROTECTED]> wrote:
> >> I find I can use django users and groups to authorize apache locations and
> >> directories using a modified version of modpython.py(I just hacked it to 
> >> check
> >> for required groups).
>
> >> I have some difficulties with this simple scheme.
>
> >> First off it seems to be completely separate from the normal django 
> >> behaviour.
> >> Is there a way to get existing django tokens to be used? So if I have 
> >> already
> >> logged in or possess a django token can I use that token to provide access 
> >> to an
> >> apache controlled area?
>
> >> Secondly the apache validation examples all seem to use mod_python as the
> >> transport between apache and django. We are tending to use fastcgi (via 
> >> flup and
> >> runfcgi) as it gives us greater flexibility; we can use an entirely 
> >> separate
> >> process for the python (perhaps even a different python). Is there a way 
> >> to use
> >> a fastcgi based validation?
>
> >> Finally, my boss wants to use a single auth database. I'm not sure that's
> >> feasible, but it seems reasonable to have a central controlled database app
> >> which only does user/groups. I think this is less desirable because of the
> >> possibility of permission leakage. I can imagine exporting changes into 
> >> some
> >> other project's db so this doesn't seem impossible.
>
> > Can you perhaps gives some code examples of what your authn/authz code
> > looks like now so I can see how you are using groups.
>
> > The reason I am curious is that I am currently working on implementing
> > a solution in mod_wsgi for better using Python to support Apache
> > authentication and authorization. Also, the other way around,
> > providing hooks so a Python application can use an Apache auth
> > provider for the auth database. This way one can have one auth
> > database across Python and non Python applications, plus static pages,
> > hosted by Apache.
>
> .
>
> OK my code looks like the standard django/contrib/auth/modpython.py the patch 
> is
>
> ***
> *** 39,44 
> --- 38,54 
>
># check the password and any permission given
>if user.check_password(req.get_basic_auth_pw()):
> + G = []  #find required groups
> + S = filter(None,map(str.split,map(str.strip,req.requires(
> + map(G.extend,[filter(None,s[1:])
> + for s in S if s[0].lower()=='group'])
> + for g in user.groups.all():
> + if g.name in G:
> + G.remove(g.name)
> +
> + if G:   #fail if required groups remain
> + return apache.HTTP_UNAUTHORIZED
> +
>if permission_name:
>if user.has_perm(permission_name):
>return apache.OK
>
> we're using this kind of phrase in our 2.0 apache configs
>
> AuthType basic
> AuthName "djauth test"
> Require valid-user
> Require group rptlab
> #AuthUserFile /home/rptlab/etc/passwd
> #AuthGroupFile /home/rptlab/etc/groups
> PythonInterpreter djauth
> PythonAuthenHandler djauth.modpython
>
> I'm guessing that AuthBasicProvider (in your examples) is new in Apache 2.2 
> and
> makes things easier for this.

Correct.

> In 2.0 there seems no way to provide another
> authorizer without writing an apache module.

Correct.

I haven't looked at how Django stores the auth database, but one other
thing which would be interesting to try, is to see if one could just
go direct to the database Django uses using the mod_authn_dbd and
mod_authz_dbd Apache modules. For an example, see:

  http://httpd.apache.org/docs/trunk/mod/mod_authz_dbd.html

Anyway I'll have a look through the code you sent. Thanks.

Graham


--~--~-~--~~~---~--~~
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: apache authorization with django

2007-09-19 Thread Robin Becker

Graham Dumpleton wrote:
.
>>
>>> In 2.0 there seems no way to provide another
>>> authorizer without writing an apache module.
>> Correct.
> 
> Whoops. Not strictly true. You can write one with mod_python by
> implementing a authzhandler(). You just need to know what you are
> doing. ;-)
> 

that's what the django approach is doing :)
-- 
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: unsupported operand type(s) for *: 'Decimal' and 'Decimal'

2007-09-19 Thread Landlord Bulfleet
We have the following weird problem, that we are unable to deliberately
replicate no matter what we try...

It seems to appears only when our server (running python2.5.1, daily updated
django svn, mod_python 3.3.1) has been running for at least maybe 4-5
hours...
After an apache restart there is no sign of the bug for another 5-7 hours...

The weird thing is that calling the view with the exactly the same
parameters usually doesn't reproduce the error.

=== sample code ===
(class1, class2) = (sum.__class__, f_c.rate.__class__)
d_sum = sum * f_c.rate
<-  break

Local vars:
class1 
class2 
sum Decimal("0.23")
=== ===

sum is property of a model object in our database
(models.DecimalField(max_digits=7,
decimal_places=2)) & f_c.rate is a  Decimal constructed using
Decimal(string) construction (Decimal is imported with "from decimal import
Decimal")

We have some doubts that this may be a result of the django's python
2.3_decimal compatibility.

Any help is appreciated...

--~--~-~--~~~---~--~~
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: Talk like a Pirate Middleware

2007-09-19 Thread Nowell

Jacob wrote something like this a while ago 
http://toys.jacobian.org/misc/pirate.py.txt

On Sep 19, 5:26 am, Scott Benjamin <[EMAIL PROTECTED]> wrote:
> Today I was looking for some middleware that would allow changing of
> the text of a site into Pirate Talk  without effecting the content, as
> today was Talk like a Pirate day.http://www.talklikeapirate.com/.
> There wasn't anything available for Django that would change site text
> into "Pirate Talk".
>
> Being inspired by some conversations on the django IRC channel, I
> decided to dig into the Middleware and attempt it myself.   After
> about spending  an hour learning Django Middleware and BeautifulSoup,
> I've finished the Talk like a Pirate middleware! I wouldn't say it's
> the best thing since sliced bread but it does work, was a blast to
> write ;)  Writing middleware was very simple.
>
> You can find more information at:
>
> http://www.scott-benjamin.com/blog/2007/sep/19/django-talk-pirate-arr...
>
> Cheers!
> Scott


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



oracle backend doesn't cache connections

2007-09-19 Thread Stefan Bethge

Hello,

i've recently found out that django does not cache connections to the
database but connects for every request and disconnects afterwards. I
don't know if this is fine for postgresql/database servers on the same
machine. Maybe using pg_pool helps a lot for postgres. However, in our
setup, we have an oracle server on another machine in the network.
Connecting to oracle takes a while, sometimes up to some seconds,
which is completely unusable for a live website. Until now, I've not
heard of a similar solution like pg_pool for oracle (and sqlrelay is
not supported for now in django, http://code.djangoproject.com/ticket/409).
Are there plans to implement some kind of connection caching or may I
have not seen a connection pool daemon for oracle?
Or is it in some way possible to manage the connections in the django
application itself?

Thanks for any suggestion,
Stefan Bethge


--~--~-~--~~~---~--~~
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 alongside other web apps

2007-09-19 Thread Graham Dumpleton

You need two separate VirtualHost definitions, one for each site. You
only have one. The ServerName directive in each VirtualHost should
match the respective site name.

Graham

On Sep 19, 7:37 pm, tonybanjo <[EMAIL PROTECTED]> wrote:
> I'm configuring a new server that needs to run a standard website
> alongside a Django application. Everything is installed correctly but
> browsing to the site goes straight to the Django app, I can't see the
> main site at all as it seems Django takes over.
>
> What I'd like to do is have a URL like this;
>
> http://www.mysite.com- the main website and this for the Django app;
>
> http://register.mysite.com
>
> The Apache config is default except for this added in the virtual
> sites section at the end of httpd.conf;
>
> 
>  # edit if changed
>  ServerName garritan.centos
>  AcceptPathInfo Off
>  
>  SetHandler python-program
>  PythonHandler django.core.handlers.modpython
>  SetEnv DJANGO_SETTINGS_MODULE garritan.settings
>  SetEnv LD_LIBRARY_PATH /usr/lib:/usr/pgsql/lib
>  PythonDebug On
>
>  # edit if paths change:
>  PythonPath "['/opt/'] + sys.path"
>  
>
>  # edit if paths change
>  Alias /media /opt/garritan/media
>
>  # this says, for static content, use apache
>  
>  SetHandler None
>  Satisfy Any
>  Allow from All
>  
> 
>
> I have tested it by running the Django app on another port and this
> works fine but it isn't how I want it to work. Any help on this would
> be greatly appreciated.
>
> Tony


--~--~-~--~~~---~--~~
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: apache authorization with django

2007-09-19 Thread Robin Becker

Graham Dumpleton wrote:
> On Sep 19, 3:05 am, Robin Becker <[EMAIL PROTECTED]> wrote:
>> I find I can use django users and groups to authorize apache locations and
>> directories using a modified version of modpython.py(I just hacked it to 
>> check
>> for required groups).
>>
>> I have some difficulties with this simple scheme.
>>
>> First off it seems to be completely separate from the normal django 
>> behaviour.
>> Is there a way to get existing django tokens to be used? So if I have already
>> logged in or possess a django token can I use that token to provide access 
>> to an
>> apache controlled area?
>>
>> Secondly the apache validation examples all seem to use mod_python as the
>> transport between apache and django. We are tending to use fastcgi (via flup 
>> and
>> runfcgi) as it gives us greater flexibility; we can use an entirely separate
>> process for the python (perhaps even a different python). Is there a way to 
>> use
>> a fastcgi based validation?
>>
>> Finally, my boss wants to use a single auth database. I'm not sure that's
>> feasible, but it seems reasonable to have a central controlled database app
>> which only does user/groups. I think this is less desirable because of the
>> possibility of permission leakage. I can imagine exporting changes into some
>> other project's db so this doesn't seem impossible.
> 
> Can you perhaps gives some code examples of what your authn/authz code
> looks like now so I can see how you are using groups.
> 
> The reason I am curious is that I am currently working on implementing
> a solution in mod_wsgi for better using Python to support Apache
> authentication and authorization. Also, the other way around,
> providing hooks so a Python application can use an Apache auth
> provider for the auth database. This way one can have one auth
> database across Python and non Python applications, plus static pages,
> hosted by Apache.
> 
.

OK my code looks like the standard django/contrib/auth/modpython.py the patch is

***
*** 39,44 
--- 38,54 

   # check the password and any permission given
   if user.check_password(req.get_basic_auth_pw()):
+ G = []  #find required groups
+ S = filter(None,map(str.split,map(str.strip,req.requires(
+ map(G.extend,[filter(None,s[1:])
+ for s in S if s[0].lower()=='group'])
+ for g in user.groups.all():
+ if g.name in G:
+ G.remove(g.name)
+
+ if G:   #fail if required groups remain
+ return apache.HTTP_UNAUTHORIZED
+
   if permission_name:
   if user.has_perm(permission_name):
   return apache.OK


we're using this kind of phrase in our 2.0 apache configs

AuthType basic
AuthName "djauth test"
Require valid-user
Require group rptlab
#AuthUserFile /home/rptlab/etc/passwd
#AuthGroupFile /home/rptlab/etc/groups
PythonInterpreter djauth
PythonAuthenHandler djauth.modpython


I'm guessing that AuthBasicProvider (in your examples) is new in Apache 2.2 and 
makes things easier for this. In 2.0 there seems no way to provide another 
authorizer without writing an apache module.
-- 
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: apache authorization with django

2007-09-19 Thread Graham Dumpleton

On Sep 19, 3:05 am, Robin Becker <[EMAIL PROTECTED]> wrote:
> I find I can use django users and groups to authorize apache locations and
> directories using a modified version of modpython.py(I just hacked it to check
> for required groups).
>
> I have some difficulties with this simple scheme.
>
> First off it seems to be completely separate from the normal django behaviour.
> Is there a way to get existing django tokens to be used? So if I have already
> logged in or possess a django token can I use that token to provide access to 
> an
> apache controlled area?
>
> Secondly the apache validation examples all seem to use mod_python as the
> transport between apache and django. We are tending to use fastcgi (via flup 
> and
> runfcgi) as it gives us greater flexibility; we can use an entirely separate
> process for the python (perhaps even a different python). Is there a way to 
> use
> a fastcgi based validation?
>
> Finally, my boss wants to use a single auth database. I'm not sure that's
> feasible, but it seems reasonable to have a central controlled database app
> which only does user/groups. I think this is less desirable because of the
> possibility of permission leakage. I can imagine exporting changes into some
> other project's db so this doesn't seem impossible.

Can you perhaps gives some code examples of what your authn/authz code
looks like now so I can see how you are using groups.

The reason I am curious is that I am currently working on implementing
a solution in mod_wsgi for better using Python to support Apache
authentication and authorization. Also, the other way around,
providing hooks so a Python application can use an Apache auth
provider for the auth database. This way one can have one auth
database across Python and non Python applications, plus static pages,
hosted by Apache.

For example, Apache configuration for Basic authentication might be:

   # Setup global auth provider definition.

   
   WSGIAuthScript /some/path/django.wsgi
   WSGIAuthenticationGroup %{GLOBAL}
   

   # Django instance mounted on '/'.

   WSGIScriptAlias / /usr/local/django/site/apache/django.wsgi

   
   WSGIApplicationGroup %{GLOBAL}
   Order deny,allow
   Allow from all
   

   # Trac instance mounted on '/trac' running in daemon process.

   WSGIDaemonProcess trac
   WSGIScriptAlias /trac /usr/local/trac/site/apache/trac.wsgi

   
   WSGIProcessGroup trac
   WSGIApplicationGroup %{GLOBAL}
   Order deny,allow
   Allow from all
   

   # Trac login uses Django auth database.

   
   AuthType Basic
   AuthName "Django"
   AuthBasicProvider django
   Require valid-user
   

The script containing the authentication routine would then be
something like:

  import os
  os.environ['DJANGO_SETTINGS_MODULE'] = 'site.settings'

  import apache.mod_auth
  from django.contrib.auth.models import User
  from django import db

  def check_password(environ, user, password):
db.reset_queries()

kwargs = {'username': req.user, 'is_active': True}

try:
try:
user = User.objects.get(**kwargs)
except User.DoesNotExist:
return apache.mod_auth.AUTH_USER_NOT_FOUND

if user.check_password(password):
return apache.mod_auth.AUTH_GRANTED
else:
return apache.mod_auth.AUTH_DENIED
finally:
db.connection.close()

Have left a few bits out here, but in short am using the Django auth
database to authenticate access to Trac.

The Apache 2.2 auth provider mechanism only deals with authentication
and there is no provider mechanism for authorisation, ie., looking to
see if a user is in a group etc. For authorisation Apache provides a
number of different modules to perform authorisation with what
condition needs to be satisfied defined by the Require directive. In
the above example mod_authz_user is relied on simply to validate that
the user existed and had valid password.

Now what I would need to provide in the way of authz functionality so
that checks could be made in Python code on whether user satisfied
some condition am not sure. This is why I was interested your actual
case of how you wanted to use groups.

Thanks in advance for any feedback.

Graham


--~--~-~--~~~---~--~~
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: sqlreset problem - a bug?

2007-09-19 Thread Kenneth Gonsalves


On 19-Sep-07, at 4:41 PM, Russell Keith-Magee wrote:

>  However, it certainly
> isn't high on my list of priorities. In the meantime, you can always
> drop and rebuild the entire database, or fall back to raw SQL DROP
> TABLE statements, managed manually.

not a problem for me as this is only the second time in two years  
that I have tried it. Just reported in case there was something wrong  
at my end.

-- 

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: sqlreset problem - a bug?

2007-09-19 Thread Russell Keith-Magee

On 9/19/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
> hi,
>
> was trying sqlreset after a long time. It does not do the drop and
> create statements in the proper order:

It never has, and in its current form, it will be very difficult to
fix. sqlreset operates on a per-app basis; however, many of the
ordering and constraint problems run across apps, and there are some
circular relationship problems that are very difficult to resolve in a
clean fashion.

Back when I was doing the fixture work I was an advocate for removing
sqlreset. The decision was made to keep because it can occasionally be
useful (when it works), and there isn't an alternative on offer at the
moment. If/when we get a schema evolution implementation into core, I
would personally expect to see the reset commands be deprecated.

Of course, in the meantime, if anyone wants to put the time into
resolving the myriad constraint issues that are involved in making
sqlreset work, they should feel free to do so. However, it certainly
isn't high on my list of priorities. In the meantime, you can always
drop and rebuild the entire database, or fall back to raw SQL DROP
TABLE statements, managed manually.

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
-~--~~~~--~~--~--~---



sqlreset problem - a bug?

2007-09-19 Thread Kenneth Gonsalves

hi,

was trying sqlreset after a long time. It does not do the drop and  
create statements in the proper order:

say table foo has a foreign key to table bar, then foo must be  
dropped first and then bar. In creation, bar must be created first  
and then foo. Otherwise, in both cases the sql fails. But sqlreset is  
creating it in the wrong order.

-- 

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: Django alongside other web apps

2007-09-19 Thread Jonathan Buchanan

On 9/19/07, tonybanjo <[EMAIL PROTECTED]> wrote:
>
> I'm configuring a new server that needs to run a standard website
> alongside a Django application. Everything is installed correctly but
> browsing to the site goes straight to the Django app, I can't see the
> main site at all as it seems Django takes over.
>
> What I'd like to do is have a URL like this;
>
> http://www.mysite.com - the main website and this for the Django app;
>
> http://register.mysite.com
>
> The Apache config is default except for this added in the virtual
> sites section at the end of httpd.conf;
>
> 
>  # edit if changed
>  ServerName garritan.centos
>  AcceptPathInfo Off
>  
>  SetHandler python-program
>  PythonHandler django.core.handlers.modpython
>  SetEnv DJANGO_SETTINGS_MODULE garritan.settings
>  SetEnv LD_LIBRARY_PATH /usr/lib:/usr/pgsql/lib
>  PythonDebug On
>
>  # edit if paths change:
>  PythonPath "['/opt/'] + sys.path"
>  
>
>  # edit if paths change
>  Alias /media /opt/garritan/media
>
>  # this says, for static content, use apache
>  
>  SetHandler None
>  Satisfy Any
>  Allow from All
>  
> 
>
> I have tested it by running the Django app on another port and this
> works fine but it isn't how I want it to work. Any help on this would
> be greatly appreciated.
>
> Tony

I've done this in the past by using a LocationMatch directive instead
of Location, as I had existing PHP applications which were also in use
on the same server:


  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE projects.settings


It helped that the Django app I was running had all its URLs mapped to
start with "release_archive".

Jonathan.

--~--~-~--~~~---~--~~
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: unknown encoding cp0

2007-09-19 Thread Nis Jørgensen

Benedict Verheyen skrev:
> Hi,
>
> a while back i updated my python isntall to version 2.5.1. on a Windows 
> 2000 server. It also runs Apache 2.2 & mod_python for Django.
> Since the python upgrade, i got this "unknown encoding cp0" error.
>
> I hadn't changed anything to the code. The errors always occured on
> print commands. I found a workaround by adding str()
> Thus
>  print "Blabla %s " % self.blabla
> had to be changed to
>  print "Blabla %s " % str(self.blabla)
> in order to solve the problem.
>   
What is "self" referring to? Can you give us a stack trace? And which
version of Django are you running (it is especially important to know if
it is before or after the unicode branch got merged).

Nis



--~--~-~--~~~---~--~~
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: reassessing our Operating System

2007-09-19 Thread Chris Hoeppner

Linux is linux after all. The kernel remains largely the same, unless
you get a patchy distro.

The choice is all about your knowledge. If you know your way around in
linux, it doesn't really matters. If you're a bit *newer*, you might
want to go with a distro with strong repos and a good package manager.

I wouldn't even consider using Windows as a server OS. Sorry for the
flames.

El mar, 18-09-2007 a las 08:02 -0500, Tim Chase escribi�:
> > Any special reasons debian based installs are better than
> > fedora based ones?
> 
> I can't say there should be any sort of major difference once 
> meta-package programs were instituted for dependency tracking. 
> My understanding is that Yum may do this sort of thing.
> 
> I tried Red Hat early in the game and grew frustrated with the 
> "yes, RPMs install easily, but you have to track down each 
> dependency individually and install it first" nature of it. 
> However, that was 5-10 years ago (around RH v5 through v8)...I've 
> just never tried an RPM-based distro since then.  If I wanted 
> dependency-tracking headaches, I'd build everything from source :)
> 
> As long as you can tell your distro "install these things I care 
> about and install any requisite dependencies you might need to in 
> order to get there", it doesn't really matter.
> 
> -tim
> 
> 
> 
> 
> > 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django alongside other web apps

2007-09-19 Thread tonybanjo

I'm configuring a new server that needs to run a standard website
alongside a Django application. Everything is installed correctly but
browsing to the site goes straight to the Django app, I can't see the
main site at all as it seems Django takes over.

What I'd like to do is have a URL like this;

http://www.mysite.com - the main website and this for the Django app;

http://register.mysite.com

The Apache config is default except for this added in the virtual
sites section at the end of httpd.conf;


 # edit if changed
 ServerName garritan.centos
 AcceptPathInfo Off
 
 SetHandler python-program
 PythonHandler django.core.handlers.modpython
 SetEnv DJANGO_SETTINGS_MODULE garritan.settings
 SetEnv LD_LIBRARY_PATH /usr/lib:/usr/pgsql/lib
 PythonDebug On

 # edit if paths change:
 PythonPath "['/opt/'] + sys.path"
 

 # edit if paths change
 Alias /media /opt/garritan/media

 # this says, for static content, use apache
 
 SetHandler None
 Satisfy Any
 Allow from All
 


I have tested it by running the Django app on another port and this
works fine but it isn't how I want it to work. Any help on this would
be greatly appreciated.

Tony


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Talk like a Pirate Middleware

2007-09-19 Thread Scott Benjamin

Today I was looking for some middleware that would allow changing of
the text of a site into Pirate Talk  without effecting the content, as
today was Talk like a Pirate day. http://www.talklikeapirate.com/ .
There wasn't anything available for Django that would change site text
into "Pirate Talk".

Being inspired by some conversations on the django IRC channel, I
decided to dig into the Middleware and attempt it myself.   After
about spending  an hour learning Django Middleware and BeautifulSoup,
I've finished the Talk like a Pirate middleware! I wouldn't say it's
the best thing since sliced bread but it does work, was a blast to
write ;)  Writing middleware was very simple.

You can find more information at:

http://www.scott-benjamin.com/blog/2007/sep/19/django-talk-pirate-arrr/

Cheers!
Scott


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



display all attributes in template

2007-09-19 Thread Michal Konvalinka

Hi group,
I would like to see all attributes for an object in my template. I can
use {% debug %} in the template but it will show only key-value pair
where pair is an object. Example:

'service': ,

I tried {{ service|pprint }} but it didn't work. Any advice?
Thanks,
Michal

--~--~-~--~~~---~--~~
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: duplicate key violates unique constraint

2007-09-19 Thread Michal

> Hmmm, could be a double-click problem (the first request creates the
> user between the check and create of the second request). I assume
> make_random_password is not the problem ...
> 
> Do you know which email/username causes the problem? Does it indeed
> exist in the db ater the operation? Before?

Yes, I know email and after inspecting DB and access.log, I could not 
found any suspicious records.

I double checked code, and could not found any potential problem. I 
contacted our hosting support, and try to solve it with them. I am 
satisfied that problems is some other place than my code :)

Regards
Michal

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



NEED TO JOIN A GROUP? 10,000 JOIN WEEKLY FREE SIGN UP!

2007-09-19 Thread dating the right mate

NEED TO JOIN A GROUP? 10,000 JOIN WEEKLY FREE SIGN UP!



http://www.blpurl.com/al42


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



unknown encoding cp0

2007-09-19 Thread Benedict Verheyen

Hi,

a while back i updated my python isntall to version 2.5.1. on a Windows 
2000 server. It also runs Apache 2.2 & mod_python for Django.
Since the python upgrade, i got this "unknown encoding cp0" error.

I hadn't changed anything to the code. The errors always occured on
print commands. I found a workaround by adding str()
Thus
 print "Blabla %s " % self.blabla
had to be changed to
 print "Blabla %s " % str(self.blabla)
in order to solve the problem.

I found a page that clarifies it a bit but it doesn't seem to provide a 
clear answer as to how to solve the problem.
 https://lists.ubuntu.com/archives/bazaar/2006q4/019418.html

Any idea as to why i suddenly got that error and is there another
way to solve it (not using str)?

Regards,
Benedict


--~--~-~--~~~---~--~~
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: ORM / Performance

2007-09-19 Thread Jarek Zgoda

yezooz napisał(a):

>>> two words: intelligent caching
>>> Know what you're asking for commonly, and cache it up with memcache.
>>> That will do you a world of benefit.
>> Well of course caching will solve some of the problems, but cache
>> still needs to regenerated sometime...
> 
> I should say that I'm thinking about few millions of pageviews a day

Memcached is designed to handle such traffic, so use it intelligently. I
mean, don't rely only on page/view caching provided with Django out of
the box, use queryset result and object cache. With reasonable
expiration time, your db will be queried rarely and you'd get your
objects nearly instantly. The other things worth putting in cache are
computed values -- if you don't mind some delays. We do such things and
the only thing I can say is that it just works, we are able to handle
many thousands of requests per minute and the sites are much more
responsible.
Unfortunately, that approach would require deleting the objects from
cache everytime they are modified, but it's a fair tradeoff IMO.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



gettext_noop usage?

2007-09-19 Thread Amit Ramon

Hello,

I read the documentation of gettext_noop and its template counterpart {% 
trans "value" noop %} and I must admit I still don't understand their use 
cases and usage.

This is what djangobook says:

x---
"Marking strings as no-op
Use the function django.utils.translation.gettext_noop() to mark a string as a 
translation string without translating it. The string is later translated 
from a variable.

Use this if you have constant strings that should be stored in the source 
language because they are exchanged over systems or users -- such as strings 
in a database -- but should be translated at the last possible point in time, 
such as when the string is presented to the user."
x---


I might be dumb, but could someone shed some light on this, and show an 
example of no-op'ed strings and late translation of it for the novice user? 
What is the use case here? How a string is translated from a variable? When?

Thanks in advance,

Amit

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How do I : Multiple table update in one form

2007-09-19 Thread John M

Ok, So have have 3+ tables all linked by various FK's and need to
update all of them on one form (or would like to).

In Windows programming this is easy (sort of), hold everthing in temp
variables and update the DB with those temp variables once the user
hit's OK.  Im still getting the hang of this HTML stuff , so bare
with me.

table1
  field1
  field2

table2 -> table1 by FK ID
  field1
  field2

table3 -> 1:1 into table2
  field1
  field2

So how would I go about creating a newform 'form' for this type of
model in HTML?  I'll take anything,

Im sort of looking for both the HTML side, and more importantly the
view for django and how to handle that.


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: regroup on a foregin key of a foreign key

2007-09-19 Thread makebelieve

I found a way around this.  I added a category attribute to the model:

class Message(models.Model):
program = models.ForeignKey(Program)
msgstr = models.TextField(null=True)

   def category(self):
   return self.program.category

so now:

{% regroup messages|dictsort:"category" by category as grouped %}

works great.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---