Re: Questions about clustering and fail over

2006-11-30 Thread Javier Rivera

El Jueves, 30 de Noviembre de 2006 23:42, Yamagami escribió:
> 2. How are the sessions stored? Is it RAM? disk? DB perhaps?

They are stored in the database, in the table django_sessions.

Javier.

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



[validators] - access to object.id field

2006-11-30 Thread Marcin Jurczuk

Hello,
I'm writing my own validator based on shipped with django and wondering
how get validated object.id field ?

Following function does not return it ..it should raised error with
message contained keys from validated object. It does but there is no
'id' field.

class ifFieldExistIsUnique(object):
def __init__(self,checked_value, error_message=gettext_lazy("Please
enter something for at least one field.")):
self.other, self.error_message = checked_value, error_message
self.always_test = True

def __call__(self,field_data,all_data):
from wtm.k.models import Customer
self.field = all_data.get(self.other)
lookup={self.other:self.field}
if len(self.field) != 0:

#sres=Customer.objects.exclude(id=all_data.get(id)).filter(**lookup)
raise validators.ValidationError, str(all_data.keys())

How pass id to valitador ?


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



Registering defaults for custom settings

2006-11-30 Thread Brian Beck

Hi,

If I'm developing middleware or an app that I want a user to be able to
configure in their settings.py, how should I go about setting defaults
in there?  I checked out django.conf, and it just looks like
global_settings.py registers the defaults for every possible module
included with Django.

So for my CAS module for example, I want some values available in
settings.py like CAS_SERVICE_URL and such, and these should have
defaults (even if they're None) so I can always access
settings.CAS_SERVICE_URL.

Here's how I'm doing it now:
defaults = {'CAS_POPULATE_USER': None,
'CAS_LOGIN_URL': '/accounts/login/',
'CAS_LOGOUT_URL': '/accounts/logout/',
'CAS_SERVICE_URL': None,
'CAS_REDIRECT_FIELD_NAME': 'next',
'CAS_REDIRECT_URL': '/',
}

for key, value in defaults.iteritems():
try:
getattr(settings, key)
except AttributeError:
setattr(settings, key, value)

So now if another app does 'from django.conf import settings', will
these additions be there or not?  Would I have to 'from cas import
settings' instead, to get a LazySettings object with these values?


--~--~-~--~~~---~--~~
 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: Re: Why not Django

2006-11-30 Thread Alan Green

On 12/1/06, James Bennett <[EMAIL PROTECTED]> wrote:

> Now, does anybody want to talk about Django?

Yes!

Is anyone writing financial or money-handling applications in Django?
Any particular issues or "gotchas" the world should know about?

a

--~--~-~--~~~---~--~~
 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: Simple CAS 1.0 authentication

2006-11-30 Thread Brian Beck

Alright, I'm gonna throw a question out there, maybe someone can help.

As shown above I can intercept the admin index page in order to not
display the login form which doesn't make sense for CAS authentication.
 However, this only works if the user needs to be authenticated and
requests the index page.  If they go directly to /admin/auth/user/ for
example, and aren't authenticated yet, it will show the login form.  I
don't want to duplicate every view in admin like I did for the index
(which just happened to be easy).  But if I had a way to intercept
every admin/ URL, do the custom authentication, then let Django
continue processing URLs (so that it would also reach
django.contrib.admin.urls), it would work.  I realize that the Root
View proposal would probably make this easy, but is it currently
possibly to tell a view to return to the URL processing phase?  Is this
a sign that my app should be middleware instead?


--~--~-~--~~~---~--~~
 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: Re: Why not Django

2006-11-30 Thread James Bennett

On 11/30/06, Istvan Albert <[EMAIL PROTECTED]> wrote:
> I think the main reason might be that when they get it wrong they don't
> have to pay the difference from their own pocket.

Depends.

The engineers will tell you it's within tolerance for the system.
The scientists will tell you it's experimental error and can be disregarded.
The mathematicians will tell you that they can't be bothered to solve
this because it's trivial.

And the programmers will tell you it's a feature ;)

Now, does anybody want to talk about Django?


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

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



Re: Why not Django

2006-11-30 Thread Istvan Albert

Fredrik Lundh wrote:

> that's probably because they're scientists, and have a pretty good
> understanding of basic math

I think the main reason might be that when they get it wrong they don't
have to pay the difference from their own pocket. 

i.


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



Re: Why not Django

2006-11-30 Thread Victor Ng

On 11/30/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Victor Ng wrote:
>
> > If user A and user B are editting the same records and you enter a
> > race where they do this:
> >
> > A) retrieve record
>
> Here you mean SELECT FOR UPDATE, right?

No, I mean SELECT.

The use case is two users are viewing the same record, and they both
go to update the same record.

That means the view code would SELECT the records into the view.  I'm
assuming you're doing SELECT FOR UPDATE and UPDATE on the POST
request/response cycle.  If you're actually doing a SELECT FOR UPDATE
on the initial request, I can't see how you're holding on to your
connection between request response cycles.

vic

--~--~-~--~~~---~--~~
 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: Dynamically modifying AdminOptions

2006-11-30 Thread noods

Oops, I made an error copying my code across. I forgot to call the
parent class' contribute_to_class method:

class RichTextField(models.TextField):
"A rich text editor field which provides a WYSIWYG editor
component."
def contribute_to_class(self, cls, name):
# Automatically add TinyMCE JavaScript libraries.
opts = cls._meta
opts.admin.js.append('js/tiny_mce/tiny_mce.js')
opts.admin.js.append('js/tiny_mce/textareas.js')
super(RichTextField, self).contribute_to_class(cls, name)

def get_manipulator_field_objs(self):
return [common_forms.RichTextField]


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



Dynamically modifying AdminOptions

2006-11-30 Thread noods

Hi all,

I'm trying to create a custom field which will automatically include
some required JavaScript libraries in the admin interface, without
having to modify contrib.admin. Currently I have a custom model field
defined as follows:

class RichTextField(models.TextField):
"A rich text editor field which provides a WYSIWYG editor
component."
def contribute_to_class(self, cls, name):
# Automatically add TinyMCE JavaScript libraries.
opts = cls._meta
opts.admin.js.append('js/tiny_mce/tiny_mce.js')
opts.admin.js.append('js/tiny_mce/textareas.js')

def get_manipulator_field_objs(self):
return [common_forms.RichTextField]

My idea was to have the field automatically append the required
JavaScript libs to the model AdminOptions js list so this would handle
everything for me, but I seem to be having some issues. I get the
following exception:

'NoneType' object has no attribute 'js'

on the first append() line, but if I do a trace print on opts.admin.js
it gives me the contents of the js list as defined in the model admin
opts, and reports it is of type list. I'm not sure why it won't let me
modify the list - and what's even weirder is I swear it was working for
me before and I'm not sure what I've done to break it.

I'm still looking into this but would appreciate any suggestions.

Cheers,

Nick


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



Re: Why not Django

2006-11-30 Thread tchoukharev

Victor Ng wrote:

> If user A and user B are editting the same records and you enter a
> race where they do this:
>
> A) retrieve record

Here you mean SELECT FOR UPDATE, right?

> B) retrieve record

Same here, right?

> A) delete record
> B) update record

As SELECT FOR UPDATE starts a transaction, these two
are in concurrent transactions, right?

> The select for update that user B uses will succeed since the select
> will simply return 0 rows.  The update will succeed because 0 rows are
> updated successfully.

The update will not be tried if its SELECT FOR UPDATE returns 0 rows,
since there is nothing to update. The UPDATE will be made only if
SELECT FOR UPDATE returns exactly 1 row. Otherwise the transaction
is rolled back and the client informed that he needs to try again (and
why). The transaction is commited after the last table is UPDATED.
On any error the transaction is rolled back.
Similar for DELETE.

Sorry, I was to be explicite that SELECT FOR UPDATE must return
1 row.

Thus, in your example either DELETE or UPDATE will fail with
a possibility for a good error message for the client.

> SELECT FOR UPDATE really only helps if the SQL commands are running
> concurrently.

They are running concurrently in your example. At least I don't see
why not.

In case you mean by 'retrieve record' something else than SELECT
FOR UPDATE, e.g. simple SELECT for GET (i.e. for the client to decide
what to do with this row). We do not start any (lasting) transaction
at this moment, just because we don't need to.

One more clarification (correction). I said 'all information from
all fields..', but I have examples of fields which might be (or might
be not) omitted from the SELECT FOR UPDATE. For one,
the last modification timestamp field.

> vic
>
> --
> "Never attribute to malice that which can be adequately explained by
> stupidity."  - Hanlon's Razor


--~--~-~--~~~---~--~~
 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 + FastCGI Problems

2006-11-30 Thread Maciej Bliziński

Mike,

I was experiencing the same problems: incomplete headers and timeouts.
I did a simple trick that made my Django application run smoothly.
Perhaps you can try the same thing (it requires simple changes). I
described it on my blog:

http://automatthias.wordpress.com/2006/12/01/django-on-dreamhost-incomplete-headers/

I haven't thoroughly verified it, it's an ongoing investigation. Maybe
you could try the same thing. I'd like to know if it works for other
people as well.

Cheers,
Maciej


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



Re: Why not Django

2006-11-30 Thread Victor Ng

On 11/30/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Even if you are right and the use of numeric is the right decision,
> still naming the fixed decimal type 'float' is, well, surprising ;-)

Agreed.  It *is* surprising.

> I will really appreciate an example showing when SELECT FOR UPDATE
> is not sufficient. GET is not important, it does not start a
> transaction in db.
> POST can be constructed even without contact to the database, it only
> should contain all information from all fields of the affected rows of
> all the affected tables (it's OK if the client just guessed all this
> information correctly), and the new information for UPDATEs.
> No long-lasting transactions involved.
> The session is needed only for authentication.

If user A and user B are editting the same records and you enter a
race where they do this:

A) retrieve record
B) retrieve record
A) delete record
B) update record

The select for update that user B uses will succeed since the select
will simply return 0 rows.  The update will succeed because 0 rows are
updated successfully.

SELECT FOR UPDATE really only helps if the SQL commands are running
concurrently.

vic

-- 
"Never attribute to malice that which can be adequately explained by
stupidity."  - Hanlon's Razor

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



Questions about clustering and fail over

2006-11-30 Thread Yamagami

Hi there,

I'm trying to evaluate if Django might be fit for a project I'm going
to be working on. The main requirement is to be bulletproof in regards
to availability even in very high volume.

I assume a setup of a few web/app servers and one or more database
servers and a load balancer (software).
Caching is good if your data doesn't need to reflect real time state of
the database. The application in question will require real time access
all the time, so caching might not be used.

I understand that Django uses the share-nothing approach, but:

1. What happens when an app server crashes? What happens to the users
on it? Are they forced to log in again? is their session lost?
2. How are the sessions stored? Is it RAM? disk? DB perhaps?

Does anyone have more information in regards to the actual setup
recommended for clustered enviroments?
I've looked around but haven't found answers to these 2 questions.

Thanks, 

Harel


--~--~-~--~~~---~--~~
 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 start server with runfcgi

2006-11-30 Thread jacobm

Hi,

I'm trying to start a project using fastcgi and am having some
problems.  (mod_python doesn't want to build on this Solaris 8 box for
some reason.)

The current problem I'm facing is that the generated manage.py script
doesn't have a runfcgi option.  When I try "./manage.py runfcgi" it
doesn't recognize the command:

$ ./manage.py runfcgi method=threaded host=127.0.0.1 port=3033
Error: Your action, 'runfcgi', was invalid.
Run "./manage.py --help" for help.
$ ./manage.py -h | grep -i cgi
$

Version info:

apache-2.0.59

mod_fastcgi-2.4.2 (installed as a DSO)

$ python
Python 2.4.4 (#1, Nov 29 2006, 16:02:45)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import flup
>>> flup.__file__
'/usr/local/python-2.4.4/lib/python2.4/site-packages/flup-0.5-r2126-py2.4.egg/flup/__init__.pyc'
>>> import django
>>> django.__path__
['/usr/local/python-2.4.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django']
>>> ^D

Any ideas?

Thanks!

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: django something wrong with many to many relationship

2006-11-30 Thread gregor

thanks man I find error, I forget pass joined attribute. Thanks Again


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



Re: Why not Django

2006-11-30 Thread tchoukharev

Victor Ng wrote:
> I find this interesting too since the use of numeric instead of a
> float is the right decision most of the time.
>
> If you're dealing with money at all - you absolutely cannot use float,
> you *must* use fixed decimal types or you risk getting into all kinds
> of really terrible rounding errors.

Even if you are right and the use of numeric is the right decision,
still naming the fixed decimal type 'float' is, well, surprising ;-)

> I'm frankly surprised that a scientific computing app is using float
> with any degree of success.

It's a lot easier to use float where fixed suits better, than other way
round.

> The long running transaction support discussed in point #1 will fail
> if data is modified between loading the initial page on GET and

Yes, it will fail, with a good explanation for the user, and that is
the desired behavior. And it is not a long running transaction in
the dbms.

> submitting data on the POST.  A simple SELECT FOR UPDATE doesn't solve
> this problem at all, you actually need a full blown unit of work
> pattern implemented on the server side that ties to your session.

I will really appreciate an example showing when SELECT FOR UPDATE
is not sufficient. GET is not important, it does not start a
transaction in db.
POST can be constructed even without contact to the database, it only
should contain all information from all fields of the affected rows of
all the affected tables (it's OK if the client just guessed all this
information correctly), and the new information for UPDATEs.
No long-lasting transactions involved.
The session is needed only for authentication.

I think I can create a model where the mentioned 'optimistic approach'
will fail, but the full described approach seems to me correct. I want
to know what I am overlooking, please help me to understand.

> vic
>
> Using floating point math is well
>
> --
> "Never attribute to malice that which can be adequately explained by
> stupidity."  - Hanlon's Razor

Best regards,
V.Chukharev


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



Help with Contact Form

2006-11-30 Thread luxagraf

Hello all I have a quick question, I just whipped up a custom
manipulator for a contact form and, following the suggestion in the
django docs, I'm using a

HttpResponseRedirect("/contact/thankyou/")

to get rid of the post data, but what I'd like to display at that
redirect url is a copy of the message the user sent... but I can't
figure out how to do that...

is there a way to do something like this:

HttpResponseRedirect("/contact/thankyou/"
extra_context={'my_form_data': data_as_list})

note that I'm not storing the message, there is no model to query to,
I thought of using a cookie, but the seems unnecessary...

any suggestions?

--~--~-~--~~~---~--~~
 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: Editing intermediary table info deletes previous data?

2006-11-30 Thread markguy

So, a solution... or maybe better called a workaround... would be to
have num_in_admin a large enough number to never need paginating. That
doesn't help when I need to update the ingredients, but at least I
could make it work.

Thanks for the heads up!


--~--~-~--~~~---~--~~
 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 getting connection.queries info

2006-11-30 Thread JP

Eric Floehr schrieb:

> from django.db import connection
> class Logging:
> def process_response(self, request, response):
> for query in connection.queries:
> print "[%s] %s" % (query['time'], "
> ".join(query['sql'].split()))
> return response
>
> Which results in all the queries being output to standard output.  Of
> course this could be improved on, but is a base.
>

A small improvement with uses coloring (a la ruby on rails):

from django.db import connection

class Logging:
def process_response(self, request, response):
from sys import stdout
if stdout.isatty():
for query in connection.queries:
print "\033[1;31m[%s]\033[0m \033[1m%s\033[0m" %
(query['time'], " ".join(query['sql'].split()))
return response

Best Regards
JP


--~--~-~--~~~---~--~~
 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 getting connection.queries info

2006-11-30 Thread Eric Floehr

Thanks James, that did the trick.  For others that may be looking, here
is my solution:

In my settings file I added below the middleware setting:

if DEBUG:
MIDDLEWARE_CLASSES += ('web.middleware.Logging',)

and in a file called "middleware.py" in my project directory (/web):

from django.db import connection
class Logging:
def process_response(self, request, response):
for query in connection.queries:
print "[%s] %s" % (query['time'], "
".join(query['sql'].split()))
return response

Which results in all the queries being output to standard output.  Of
course this could be improved on, but is a base.

Thanks again,
Eric


--~--~-~--~~~---~--~~
 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: Initial data for models splitted across multiple files

2006-11-30 Thread Mikko Suniala

On Thu, 30 Nov 2006, Russell Keith-Magee wrote:
> Sounds like a bug in the way that manage.py discovers the module in which
> the sql files are located. This is entirely possible, as the 'split models
> across files' approach isn't the common use case for Django models.

Ok. Since the recipe seems to be some sort of a hack I guess it does not 
make sense to file a bug just because something does not work as expected 
when the recipe is applied. However, I added a note to the recipe.


Mikko

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



Re: Why not Django

2006-11-30 Thread Victor Ng

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

Basic currency conversion for Euro would require 5 decimal places of
precision with no rounding involved:
http://europa.eu.int/ISPO/y2keuro/docs/ep22-en.pdf

Really, float isn't the answer for anything relating to money - normal
or otherwise.

vic

--~--~-~--~~~---~--~~
 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: {# comments? #} and django update process via svn

2006-11-30 Thread Adrian Holovaty

On 11/30/06, hotani <[EMAIL PROTECTED]> wrote:
> I noticed in the most recent documentation that we should now be able
> to use the {# comment #} multi-line commenting tags in templates.
> However, after doing an 'svn update' and restarting apache it does not
> seem to be available. Which begs the question: am I not fully updating?
> Is there something else I should be doing to complete the update
> process?

Hi hotani,

The {# syntax #} only works for single-line comments. For multi-line
comments, use the old style:

{% comment %}{% endcomment %}

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Simple CAS 1.0 authentication

2006-11-30 Thread Brian Beck

Quick followup in case anyone is interested (anyone? Bueller?)...

One problem is handling the admin site, which doesn't really account
for an authentication backend that doesn't know the user's password
(making the login form useless).  So, without wanting to hack up
django.contrib.admin, here's what I came up with...

In cas/views.py, add an admin view:

def admin(request):
if request.user.is_authenticated():
if request.user.is_staff:
from django.contrib.admin.views.main import index
return index(request)
else:
error = "ForbiddenYou do not have staff
privileges."
return HttpResponseForbidden(error)
params = urlencode({'next': request.get_full_path()})
return HttpResponseRedirect('/accounts/login/?' + params)

Then just make sure your URLconf finds that view before the admin login
page:
(r'^admin/$', 'present.cas.views.admin'),
(r'^admin/', include('django.contrib.admin.urls')),

So I think this will only work when the user needs to authenticate at
/admin/ (and not if they lose authentication doing some other admin
request), but for now it 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
-~--~~~~--~~--~--~---



Secure downloads in Django

2006-11-30 Thread kwe

If you're using lighttpd and fcgi to run your Dajngo app, here's a
short article on using modsecdownload -
http://isdevelopment.weblog.glam.ac.uk/news/2006/nov/30/secure-downloads-django/


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



{# comments? #} and django update process via svn

2006-11-30 Thread hotani

I noticed in the most recent documentation that we should now be able
to use the {# comment #} multi-line commenting tags in templates.
However, after doing an 'svn update' and restarting apache it does not
seem to be available. Which begs the question: am I not fully updating?
Is there something else I should be doing to complete the update
process?


--~--~-~--~~~---~--~~
 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: Inheritance through a ForeignKey field

2006-11-30 Thread yun

Suppose that you have a Section model that has a foreign key to
Magazine, and the field in the Section model is called magazine. You
can then do something like this once you get the section:

s = Section.objects.select_related.get()
s.magazine.id will return the id of the magazine, if it has a name then
s.magazine.name will return the name.

This will do the all the related querries in one shot. You can also do:

s = Section.objects.get()
s.magazine.id will still return the mangazine id, but it will also
query the database twice. Once to get the Section object, then second
time to get the details fo the magazine object.

Assuming that you want to put this into a form, you'll probably have to
do something like:

new_data['magazine'] = s.magazine.id

in the forms page.

Hope that this helps.


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



Re: Why not Django

2006-11-30 Thread Jeremy Dunck

On 11/30/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> basically claimed that if someone pays you $5.999 for a
> $6.00 product, you've lost a full dollar ;-)

Clearly, we should have an infinite number of bits, and then refer
them to something like this:
http://www.newton.dep.anl.gov/newton/askasci/1995/math/MATH070.HTM

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



Re: Why not Django

2006-11-30 Thread Fredrik Lundh

Victor Ng wrote:

 > If you're dealing with money at all - you absolutely cannot use float,
 > you *must* use fixed decimal types or you risk getting into all kinds
 > of really terrible rounding errors.

that might be true for the US deficit, but for more normal money 
amounts, that's not really true at all.

> I'm frankly surprised that a scientific computing app is using float
> with any degree of success.

that's probably because they're scientists, and have a pretty good 
understanding of basic math (unlike the recent c.l.python poster who 
basically claimed that if someone pays you $5.999 for a
$6.00 product, you've lost a full dollar ;-)




--~--~-~--~~~---~--~~
 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: Re: Retrieve Password

2006-11-30 Thread Felix Ingram

On 30/11/06, James Bennett <[EMAIL PROTECTED]> wrote:
> In general, I think this is a tradeoff we've had to make to have
> Django be as useful as it is -- the goal isn't to satisfy *every* case
> out of the box, but to satisfy *common* cases out of the box with the
> ability to extend things as needed. And in my experience doing web
> development, wanting secure password storage is the much more common
> case ;)

For varying definitions of secure I'm sure ;-)

My point was really that we should be careful of preaching the 'right'
way of doing things. 'Common' things, now they're fine. :-)

Felix

--~--~-~--~~~---~--~~
 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 something wrong with many to many relationship

2006-11-30 Thread Victor Ng

Your error is in your logs:

ProgrammingError: ERROR:  null value in column "age" violates not-null
constraint

You need to specify an age value, or define age=models.IntegerField(null=True)

vic

On 11/30/06, gregor <[EMAIL PROTECTED]> wrote:
>
> Hello i have manytomany relations (database PostgreSql 8.1.5) like
> this:
> class Photograph(models.Model):
> name = models.CharField(maxlength=200)
> email = models.EmailField()
> age = models.IntegerField()
> categories = models.ManyToManyField(Category)
> joined = models.DateField()
> albums = models.IntegerField()
> photos = models.IntegerField()
> county = models.ForeignKey(County)
> city = models.ForeignKey(City)
> class Category(models.Model):
> name = models.CharField(maxlength=15)
>
> I create some Categories like that:
>  category = Category(name='weddings')
> category.save()
> and then I create a photograph and here is a problem:
> In [8]: p = Photograph(name="p", email="[EMAIL PROTECTED]",albums=26,
> photos=12,city=city, county=county, categories=category)
> ---
> exceptions.TypeError Traceback (most
> recent call last)
>
>
> C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\base.py
> in __init__(self, *args, **kwargs)
> 123 pass
> 124 if kwargs:
> --> 125 raise TypeError, "'%s' is an invalid keyword
> argument for this function" % kwargs.keys()[0]
> 126 for i, arg in enumerate(args):
> 127 setattr(self, self._meta.fields[i].attname, arg)
>
> TypeError: 'categories' is an invalid keyword argument for this
> function
>
>
> or if try to save:
>
>
> Photograph.save()
> In [19]: p = Photograph(name="Smith",email="[EMAIL PROTECTED]",albums=26,
> photos=34, county=woj, city=miasto)
>
> In [20]: p.save()
> ---
> psycopg.ProgrammingError  Traceback (most
> recent call last)
>
> I:\Prace\PRYWATNE\DJANGO_projekty\moremoments\
>
> C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\base.py
> in save(self)
> 202 cursor.execute("INSERT INTO %s (%s) VALUES
> (%s)" % \
> 203 (backend.quote_name(self._meta.db_table),
> ','.join(field_names),
> --> 204 ','.join(placeholders)), db_values)
> 205 else:
> 206 # Create a new record with defaults for
> everything.
>
> C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\backends\util.py
> in execute(self, sql, params)
>  10 start = time()
>  11 try:
> ---> 12 return self.cursor.execute(sql, params)
>  13 finally:
>  14 stop = time()
>
> ProgrammingError: ERROR:  null value in column "age" violates not-null
> constraint
>
> INSERT INTO "mm_photograph"
> ("name","email","age","joined","albums","photos","county_id","city_id")
> VALUES ('Smith','smi
> [EMAIL PROTECTED]',NW
>
> or i try to add category:
> n [21]: p.categories.add(kategoria)
> --
> xceptions.ValueErrorTraceback (most
> recent call last)
>
> :\Prace\PRYWATNE\DJANGO_projekty\moremoments\
>
> :\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\fields\related.py
> in __get__(self, instance, in
> tance_type)
>437 join_table=qn(self.field.m2m_db_table()),
>438 source_col_name=qn(self.field.m2m_column_name()),
> -> 439 target_col_name=qn(self.field.m2m_reverse_name())
>440 )
>441
>
> :\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\fields\related.py
> in __init__(self, model, core
> filters, instance, symmetrical, join_table, source_col_name,
> target_col_name)
>276 self._pk_val = self.instance._get_pk_val()
>277 if self._pk_val is None:
> -> 278 raise ValueError("%r instance needs to have a
> primary key value before a many-to-many relationsh
> p can be used." % model)
>279
>280 def get_query_set(self):
>
> ValueError:  instance needs to
> have a primary key value before a many-to-many re
> ationship can be used.
>
>
> So what I'm doing wrong??
> Any one help me, please
>
>
> >
>


-- 
"Never attribute to malice that which can be adequately explained by
stupidity."  - Hanlon's Razor

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

django something wrong with many to many relationship

2006-11-30 Thread gregor

Hello i have manytomany relations (database PostgreSql 8.1.5) like
this:
class Photograph(models.Model):
name = models.CharField(maxlength=200)
email = models.EmailField()
age = models.IntegerField()
categories = models.ManyToManyField(Category)
joined = models.DateField()
albums = models.IntegerField()
photos = models.IntegerField()
county = models.ForeignKey(County)
city = models.ForeignKey(City)
class Category(models.Model):
name = models.CharField(maxlength=15)

I create some Categories like that:
 category = Category(name='weddings')
category.save()
and then I create a photograph and here is a problem:
In [8]: p = Photograph(name="p", email="[EMAIL PROTECTED]",albums=26,
photos=12,city=city, county=county, categories=category)
---
exceptions.TypeError Traceback (most
recent call last)


C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\base.py
in __init__(self, *args, **kwargs)
123 pass
124 if kwargs:
--> 125 raise TypeError, "'%s' is an invalid keyword
argument for this function" % kwargs.keys()[0]
126 for i, arg in enumerate(args):
127 setattr(self, self._meta.fields[i].attname, arg)

TypeError: 'categories' is an invalid keyword argument for this
function


or if try to save:


Photograph.save()
In [19]: p = Photograph(name="Smith",email="[EMAIL PROTECTED]",albums=26,
photos=34, county=woj, city=miasto)

In [20]: p.save()
---
psycopg.ProgrammingError  Traceback (most
recent call last)

I:\Prace\PRYWATNE\DJANGO_projekty\moremoments\

C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\base.py
in save(self)
202 cursor.execute("INSERT INTO %s (%s) VALUES
(%s)" % \
203 (backend.quote_name(self._meta.db_table),
','.join(field_names),
--> 204 ','.join(placeholders)), db_values)
205 else:
206 # Create a new record with defaults for
everything.

C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\backends\util.py
in execute(self, sql, params)
 10 start = time()
 11 try:
---> 12 return self.cursor.execute(sql, params)
 13 finally:
 14 stop = time()

ProgrammingError: ERROR:  null value in column "age" violates not-null
constraint

INSERT INTO "mm_photograph"
("name","email","age","joined","albums","photos","county_id","city_id")
VALUES ('Smith','smi
[EMAIL PROTECTED]',NW

or i try to add category:
n [21]: p.categories.add(kategoria)
--
xceptions.ValueErrorTraceback (most
recent call last)

:\Prace\PRYWATNE\DJANGO_projekty\moremoments\

:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\fields\related.py
in __get__(self, instance, in
tance_type)
   437 join_table=qn(self.field.m2m_db_table()),
   438 source_col_name=qn(self.field.m2m_column_name()),
-> 439 target_col_name=qn(self.field.m2m_reverse_name())
   440 )
   441

:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\fields\related.py
in __init__(self, model, core
filters, instance, symmetrical, join_table, source_col_name,
target_col_name)
   276 self._pk_val = self.instance._get_pk_val()
   277 if self._pk_val is None:
-> 278 raise ValueError("%r instance needs to have a
primary key value before a many-to-many relationsh
p can be used." % model)
   279
   280 def get_query_set(self):

ValueError:  instance needs to
have a primary key value before a many-to-many re
ationship can be used.


So what I'm doing wrong??
Any one help me, please


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



Inheritance through a ForeignKey field

2006-11-30 Thread phess

I'm now building an online magazine website. Each magazine has the same
set of sections. And every article belongs to one and only one section.

So, the Article class has a ForeignKey(Section) line.

So far, so good (I guess). :)

But there are actually 2 magazines, each with its own group of
sections. When I create an article, I want the "Section" field in the
form to automatically load the "Magazine" field in the same form.

Does django handle this kind of thing?


--~--~-~--~~~---~--~~
 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: Re: Retrieve Password

2006-11-30 Thread James Bennett

On 11/30/06, Felix Ingram <[EMAIL PROTECTED]> wrote:
> The 'right' way of securing an application is very much dependant on
> the application itself and the function it is trying to perform.
> Storing password hashes is a way to mitigate the risks associated with
> someone gaining access to the database. There may be cases where this
> is not appropriate.

And in those cases, someone who doesn't want a hashed password can
easily write a custom auth backend (which is an extremely simple thing
to do), or a user profile module which stores the plaintext password.

In general, I think this is a tradeoff we've had to make to have
Django be as useful as it is -- the goal isn't to satisfy *every* case
out of the box, but to satisfy *common* cases out of the box with the
ability to extend things as needed. And in my experience doing web
development, wanting secure password storage is the much more common
case ;)


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

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



Re: When Django downward compatibility version is available?

2006-11-30 Thread [EMAIL PROTECTED]

Form handling/manipulators will change before 1.0 so also current
SVN/0.95 will need some upgrade. For a new project use SVN


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

2006-11-30 Thread Hull, Dave

Check out the bottom of the tutorial (before the Comments section) at
http://www.djangoproject.com/documentation/tutorial2/

There's a line that begins "For full details on customizing the look and
feel of the Django admin site..."

I'm guessing you can copy the templates for the admin site into your
local templates directory and modify them to your heart's content. 

Hope this helps. Lord knows I need some help getting much past what's in
the tutorial and book so far.

-- 
Dave
Living just a few blocks down the road from the Journal World.

-Original Message-
From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Jim Fritchman
Sent: Wednesday, November 29, 2006 5:55 AM
To: Django users
Subject: Help with admin views


I am hoping some of you can give me a little start as to where I can
read how to alter some of the admin pages.

I have a a Person class in my model and I want to change both the view
of people plus I want to change the form page where people are added and
deleted.

Any links or examples or tutorials who greatly be appreciated.

Thank,
Jim




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



When Django downward compatibility version is available?

2006-11-30 Thread Pythoni

I have already 3 projects in 0.91 version. Now I am going to start
another project that will be similar to one of those 3 already running
projects.

Shall I use
- 0.95 version,
- the latest svn version,
-wait for 1.0 version( that I expect it to be  downward compatible)
- use 0.91 version because I can use about 80% from the one of those
already running projects


What would you suggest?

Thank you
L.


--~--~-~--~~~---~--~~
 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM

2006-11-30 Thread Rock

Yeah it is all coming back to me. I was unwilling to answer all of
these questions and create the perfect solution (which may not exist)
and therefore we don't have aggregates in Django even though I
demonstrated that a straightforward implementation was possible way
back when. Thanks for backing me up on that Russ. ;)

What I am pondering in the meantime is whether or not to do a fork of
Django someday that concentrates more on scientific presentations
rather than newspapers. In DjangoSci (or perhaps TechnoDjango) there
would be a lot of attention to data reduction, statistical processing,
queries oriented towards returning graphable data sets and, of course,
true floating point data representations in the database. I am willing
to wait for Malcom to finish his work before making this monumental
move. I will also look over SQLAlchemy.

The desire to mold a version of Django (or Django itself) to better
handle the needs of the technical/scientific market does not in any way
represent a slap at Django itself or its' many paid and volunteer
developers. Django rocks! It has become a core capability in my
development group. We already have 3 elaborate and highly visible
internal applications based on Django and our ability to quickly
respond to requests for improvements has changed the dynamics of how
our entire division does much of its work.


Rock


On Nov 29, 11:51 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 11/30/06, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
> > I think for those who need aggregate data these would cover a lot of
> > ground.  I'd be willing to work on a patch if this is considered
> > generally useful and we can work out what the API should look like.1 - I'm 
> > agreed on the need for easier access to aggregates. Truth be told,
> aggregates are the reason I got involved with Django in the first place.
> However, other priorities have arisen in the meantime, so I haven't got
> around to doing anything about them.
>
> 2 - Keep in mind that Malcolm has been working on refactoring
> django.db.models.query. Until this refactor is committed, we are trying to
> minimize the number of large changes to query.py.
>
> 3 - Also keep in mind that one of the goals of the SQLAlchemy branch is to
> make complex aggregates (such as those requiring group_by and having) easier
> to represent. That said, there doesn't appear to have been a lot of progress
> on this branch (at least, not in public commits, anyway).
>
> 4 - If you search the archives (user and developer), you will find several
> discussions on aggregate functions. group_by() and having() (or
> pre-magic-removal analogs thereof) have been rejected previously on the
> grounds that the Django ORM is not intended to be 'SQL with a different
> syntax'. Any proposal for group_by/having will have to be logical from a
> Django ORM point of view, and not presuppose/require knowledge of how SQL
> formulates queries.
>
> 5 - The aggregates you suggest are the quick and obvious method for getting
> aggregates into the query language. However, here are some issues to
> consider:
>
> Article.objects.count() return an integer that is the count of all author
> objects. This makes sense, and syntactically parses the same way that it
> operates.
>
> However, what does Article.objects.max('pagecount') return? The integer that
> is the largest page count, or the Article that has the largest pagecount?
>
> If it is the former, how do you use the maximum value to get the Article
> with that maximum value in a single query?
>
> If it is the latter, does it return a single object, or a queryset that
> evaluates to an object?
>
> What happens if there are two objects with the same maximum pagecount?
>
> How do you get multiple aggregates for a value in a single query (efficiency
> matters)?
>
> How does the simple case fit into the big picture? Ideally, the simple min()
> would be a degenerate case of the min-with-group by-and-having. Prove to me
> that adding min(), max(), etc isn't going to become a wart that we have to
> support into the future when 'aggregate clauses 3000' is added to Django's
> query syntax.
>
> So, as you can see - it's not as simple as 'just add a min() where count()
> is already'.
>
> Like I said at the beginning, I'm keen to see aggregates implemented - I
> just want to see them done right. There are many things that _could_ be done
> to implement aggregates; whether they are the _right_ thing to do is another
> matter entirely. I'm open to any discussion on this issue, and would be
> happy to help shepard any patches resulting from the discussion into the
> 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 

Re: Populating select field in custom manipulator

2006-11-30 Thread [EMAIL PROTECTED]

The choices parameter to Selectfield expects a list of tuples, what
you've got is a list of strings.
Say you want to have to choices in the selectfield, it would go
something like this.

projects = [("choice1","Gen2"),("choice2","CRMC")]

I hpoe that clears things up for you ..

-- Torbjørn


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



Multithreading inside django

2006-11-30 Thread Wolfram Kriesing

>From the frontend I trigger via AJAX a view that again starts a thread
that does some import work, that might take quite a while. This
enables the user to keep going and have the import run without
interrupting him/her. Every once in a while an asynch call checks on
the state of the import.

And here lies the problem: while the thread is running and busy like a
bee adding data in the DB the asynch call to check on the state also
tries to run a query and that causes the following exception:

Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/threading.py",
line 442, in __bootstrap
self.run()
  File "/Users/cain/programming/pms/trunk/pm/../pm/core/views/pic.py",
line 204, in run
self._save(kwargs, sizes, thumbnail_url)
  File "/Users/cain/programming/pms/trunk/pm/../pm/core/views/pic.py",
line 211, in _save
picimport.save()
  File "/Users/cain/programming/django/trunk/django/db/models/base.py",
line 184, in save
db_values + [pk_val])
  File "/Users/cain/programming/django/trunk/django/db/backends/util.py",
line 12, in execute
return self.cursor.execute(sql, params)
  File "/Users/cain/programming/django/trunk/django/db/backends/mysql/base.py",
line 42, in execute
return self.cursor.execute(sql, params)
  File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/MySQLdb/cursors.py",
line 137, in execute
self.errorhandler(self, exc, value)
  File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/MySQLdb/connections.py",
line 33, in defaulterrorhandler
raise errorclass, errorvalue
ReferenceError: weakly-referenced object no longer exists

I had found the ticket http://code.djangoproject.com/ticket/1442 which
looks like it did solve my problem. So where does my problem come
from?
Is the problem caused by using multiple cursors (as I would guess from
the traceback)? Any ideas?

Thanks in advance

-- 
cu

Wolfram

--~--~-~--~~~---~--~~
 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: General File Upload Questions.

2006-11-30 Thread patrick k.


Am 30.11.2006 um 14:26 schrieb Paul Childs:

>
> I have been investigating file uploads in general and also with Django
> in mind. This thread gave me a place to start:
> http://tinyurl.com/ymzmds
>  7b8d81917f741eea/6025c02beec9ae29?rnum=1=maximum+upload 
> +size&_done=%2Fgroup%2Fdjango-users%2Fbrowse_frm%2Fthread% 
> 2F7b8d81917f741eea%3Ftvc%3D1%26q%3Dmaximum+upload+size% 
> 26#doc_6025c02beec9ae29>
>
> I have a few questions..
>
> 1. Is there an upper limit to the size of files that one can upload to
> Django? I am able to upload files of about 5 MB or less with no
> problems, but when I try to upload a file (to the Django dev server)
> which is larger I get an error message from Django. (Traceback is
> below)

since you´re uploading to your server (and not to django), you have  
to use the apache-config (if you´re using apache):
see http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody

>
> 2. Does anyone know of a *simple* client-side javascript that would
> enable client side checking of a file's size? I have seen quite a few
> progress bars which have way more features than I need. I would just
> like to put a cap on the size of an uploaded file and stop the upload
> *before* the whole file is sent to the web server and handed over to
> the view.

I don´t think that´s possible. you can get the filesize after  
uploading, but not before.

there have been other threads concerning this topic. doing a "search"  
on the django user-group might help.

patrick

>
> Thanks,
> /Paul
>
> Traceback (most recent call last):
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \servers\basehttp.py",
> line 272, in run
> self.result = application(self.environ, self.start_response)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \servers\basehttp.py",
> line 615, in __call__
> return self.application(environ, start_response)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \handlers\wsgi.py",
> line 148,
>  in __call__
> response = self.get_response(request.path, request)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \handlers\base.py",
> line 102,
>  in get_response
> return self.get_technical_error_response(request)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \handlers\base.py",
> line 134,
>  in get_technical_error_response
> return debug.technical_500_response(request, *sys.exc_info())
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\views 
> \debug.py",
> line 131, in tec
> hnical_500_response
> return HttpResponseServerError(t.render(c), mimetype='text/html')
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template 
> \__init__.py",
> line 155,
> in render
> return self.nodelist.render(context)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template 
> \__init__.py",
> line 688,
> in render
> bits.append(self.render_node(node, context))
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template 
> \__init__.py",
> line 716,
> in render_node
> raise wrapped
> TemplateSyntaxError: Caught an exception while rendering:
>
> Original Traceback (most recent call last):
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template 
> \__init__.py",
> line 706,
> in render_node
> result = node.render(context)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template 
> \__init__.py",
> line 752,
> in render
> output = self.filter_expression.resolve(context)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template 
> \__init__.py",
> line 548,
> in resolve
> obj = resolve_variable(self.var, context)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template 
> \__init__.py",
> line 634,
> in resolve_variable
> current = current[bits[0]]
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\http 
> \__init__.py",
> line 31, in __
> getitem__
> for d in (self.POST, self.GET):
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \handlers\wsgi.py",
> line 99,
> in _get_post
> self._load_post_and_files()
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \handlers\wsgi.py",
> line 77,
> in _load_post_and_files
> self._post, self._files = http.parse_file_upload(header_dict,
> self.raw_post_data)
>   File
> "c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core 
> \handlers\wsgi.py",
> line 122,
>  in _get_raw_post_data
> self._raw_post_data =
> self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"]))
>   File "C:\Python24\lib\socket.py", line 303, in read
> data = self._sock.recv(recv_size)
> MemoryError
>
> [30/Nov/2006 13:06:24] "POST /doc/update/49/ 

General File Upload Questions.

2006-11-30 Thread Paul Childs

I have been investigating file uploads in general and also with Django
in mind. This thread gave me a place to start:
http://tinyurl.com/ymzmds


I have a few questions..

1. Is there an upper limit to the size of files that one can upload to
Django? I am able to upload files of about 5 MB or less with no
problems, but when I try to upload a file (to the Django dev server)
which is larger I get an error message from Django. (Traceback is
below)

2. Does anyone know of a *simple* client-side javascript that would
enable client side checking of a file's size? I have seen quite a few
progress bars which have way more features than I need. I would just
like to put a cap on the size of an uploaded file and stop the upload
*before* the whole file is sent to the web server and handed over to
the view.

Thanks,
/Paul

Traceback (most recent call last):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 272, in run
self.result = application(self.environ, self.start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 615, in __call__
return self.application(environ, start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 148,
 in __call__
response = self.get_response(request.path, request)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py",
line 102,
 in get_response
return self.get_technical_error_response(request)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py",
line 134,
 in get_technical_error_response
return debug.technical_500_response(request, *sys.exc_info())
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\views\debug.py",
line 131, in tec
hnical_500_response
return HttpResponseServerError(t.render(c), mimetype='text/html')
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 155,
in render
return self.nodelist.render(context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 688,
in render
bits.append(self.render_node(node, context))
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 716,
in render_node
raise wrapped
TemplateSyntaxError: Caught an exception while rendering:

Original Traceback (most recent call last):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 706,
in render_node
result = node.render(context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 752,
in render
output = self.filter_expression.resolve(context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 548,
in resolve
obj = resolve_variable(self.var, context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 634,
in resolve_variable
current = current[bits[0]]
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\http\__init__.py",
line 31, in __
getitem__
for d in (self.POST, self.GET):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 99,
in _get_post
self._load_post_and_files()
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 77,
in _load_post_and_files
self._post, self._files = http.parse_file_upload(header_dict,
self.raw_post_data)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 122,
 in _get_raw_post_data
self._raw_post_data =
self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"]))
  File "C:\Python24\lib\socket.py", line 303, in read
data = self._sock.recv(recv_size)
MemoryError

[30/Nov/2006 13:06:24] "POST /doc/update/49/ HTTP/1.1" 500 3110
Traceback (most recent call last):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 2
72, in run
self.result = application(self.environ, self.start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 6
15, in __call__
return self.application(environ, start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 148,
 in __call__
response = self.get_response(request.path, request)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py",
line 102,
 in get_response
return self.get_technical_error_response(request)
  File

Re: Retrieve Password

2006-11-30 Thread Felix Ingram

On 29/11/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On 11/29/06 12:50 PM, Clint74 wrote:
> > I need to send the password to the user(email), but how recover the raw
> > password once the database stores in this format:
>
> You can't; that's the point of hashing it.  The right (read: secure) way to
> deal with this is to *reset* the user's password (usually to something random,
> which they then can change when they log in) rather than sending their
> password in plaintext.

The 'right' way of securing an application is very much dependant on
the application itself and the function it is trying to perform.
Storing password hashes is a way to mitigate the risks associated with
someone gaining access to the database. There may be cases where this
is not appropriate.

For example, if the application is only used by a few trusted users
who's passwords are used to encrypt data then password resetting is a
very bad idea. If you're setting up your own online bank and using
third party hosting for your database servers then yes, maybe you
should hash your users' passwords.

Just a thought.

Felix

--~--~-~--~~~---~--~~
 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: Updating and saving a related record. How does it work?

2006-11-30 Thread Aidas Bendoraitis

Have you tried Jacob's suggestion with the model, or its instance? You
should have done that with an instance.

I would also advice you to use lower case for
variables(instances)/functions and capitalized words only for
classes(models). Otherwise you confuse yourself and people who might
help you.

Good luck!
Aidas Bendoraitis [aka Archatas]



On 11/29/06, MerMer <[EMAIL PROTECTED]> wrote:
>
> I am finding that the following intermediate step is required.
>
> Comp=Promo.competition
>
> This changes the class from Promotion to Competition and I can then
> make the changes
>
> Comp.total_value=3000
> Comp.save()
>
> However, I'm no wiser why the earlier solution by Jacob is not working
> for me. Intuitively,
> it should.
>
> MerMer
>
>
> >
>

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