Re: Flup:Unhandled Exception

2009-02-08 Thread Dj Gilcrease

On Sun, Feb 8, 2009 at 11:17 PM, madhav  wrote:
> checked the lighttpd logs, all I see is "Interface Error/Connection
> already closed." Its only occuring when my applicaiton is running in
> FCGI mode. so the problem is with how flup is actually dealing with my
> code(application).

This actually sounds like the error I was getting when lighttpd was
attempting to execute my site as plain CGI and not FCGI, been a while
since I fixed it so I dont remember the exact error

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Flup:Unhandled Exception

2009-02-08 Thread madhav

Hi all,
I am facing the dreaded "Unhandled Exception" raised by Flup. The sad
part is its raised at the webserver(lighttpd+flup) level and not at
the application level(Django). So no 500 email is raised about where
the problem is. Our entire team struggled hard to cleanup the
codebase, incase of any ambigous imports and someones of that sort,
just to be eliminate the chances of raising errors due to the
ambiguous imports. And we cleaned up many things in the code. Still
the same exception. To be frank I am really frustrated with Flup's
error handling. It doesn't tell you anything, worst of all, it shows
the same "Unhandled Exception" to the Users. How do I get pass this. I
checked the lighttpd logs, all I see is "Interface Error/Connection
already closed." Its only occuring when my applicaiton is running in
FCGI mode. so the problem is with how flup is actually dealing with my
code(application). How do I get pass this. I checked for alternatives
for flup, but Django depends on flup explicitly(which is one more
restriction, and puzzled me)(Reference:django_src/django/core/servers/
fastcgi.py line:100 / 131)

How do I debug(atleast) this scenario and solve the problem? Please
help me out. The application is down since 3 days. :(
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What is the Difference between get() and filter() functions in Django Framework

2009-02-08 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 12:37 AM, gganesh  wrote:

>
> hi ,
> help to find the difference between get() and filter()  function in
> django ,both seems to retrieve records from data base .
> Thanks
>
> >
>
filter() returns another QuerySet, that is it returns multiple objects,
get() returns a single object and raises an exception if either more than 1
object are returned, or none are returned.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



What is the Difference between get() and filter() functions in Django Framework

2009-02-08 Thread gganesh

hi ,
help to find the difference between get() and filter()  function in
django ,both seems to retrieve records from data base .
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Django and HTTP Request

2009-02-08 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 12:28 AM, Vitaly Babiy  wrote:

> Yeah, it does. I am going to have to look to see if can find a better stand
> alone server to do this instead of patching django.
>
> Vitaly Babiy
>
>
> On Mon, Feb 9, 2009 at 12:22 AM, Alex Gaynor wrote:
>
>>
>>
>> On Mon, Feb 9, 2009 at 12:18 AM, Vitaly Babiy  wrote:
>>
>>> Yea, but I see a few problems whit that solution:
>>>
>>>- Hacky
>>>- Still not guaranteed to work( it could take more time)
>>>- Would really slow down the tests
>>>
>>> Vitaly Babiy
>>>
>>>
>>> On Mon, Feb 9, 2009 at 12:15 AM, Alex Gaynor wrote:
>>>


 On Mon, Feb 9, 2009 at 12:13 AM, Vitaly Babiy wrote:

> Right the problem is if I reload the server on ever test, there is not
> enough time for the thread to kill the server. So when the next setUp 
> comes
> around the port is still in use.
> I think I need to find a way to start a HTTP server at the beginning of
> the test and keep it around till all test are done. And have a way to tell
> the server what to return on the request.
>
> Vitaly Babiy
>
>
> On Mon, Feb 9, 2009 at 12:08 AM, Alex Gaynor wrote:
>
>>
>>
>> On Mon, Feb 9, 2009 at 12:06 AM, Vitaly Babiy wrote:
>>
>>> Hello everyone,
>>>
>>> I am working on a project that will need to make a request out to the
>>> web and pull down some data, For testing purpose I was wonder what 
>>> would be
>>> the best way to test this. I don't want to make the actual request 
>>> during
>>> the test, because for one if I am off-line all those tests will fail.
>>>
>>> I have tried to implement a HTTPServer in python. The problem I am
>>> having is once I have it thread, If I put it in the setUp method  and
>>> tearDown I get port in use exception. Due to the nature of the thread 
>>> it is
>>> not guaranteed to be killed in time.
>>>
>>> Vitaly Babiy
>>>
>>>
>>>
>> You should be able to save the thread on the Test object during
>> setup() and then kill it on teardown() shouldn't you?
>>
>> Alex
>>
>> --
>> "I disapprove of what you say, but I will defend to the death your
>> right to say it." --Voltaire
>> "The people's good is the highest law."--Cicero
>>
>>
>>
>
>
>
 What if you just put a time.sleep(2) at the end of tearDown() that
 should give the thread enough time to close before the next test starts.


 Alex

 --
 "I disapprove of what you say, but I will defend to the death your right
 to say it." --Voltaire
 "The people's good is the highest law."--Cicero



>>>
>>>
>>>
>> Is what you are ultimately searching for similar to this:
>> http://code.djangoproject.com/ticket/2879
>>
>>
>> Alex
>>
>> --
>> "I disapprove of what you say, but I will defend to the death your right
>> to say it." --Voltaire
>> "The people's good is the highest law."--Cicero
>>
>>
>>
>
> >
>
The CherryPy WSGI server is usually a good choice for these things.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Django and HTTP Request

2009-02-08 Thread Vitaly Babiy
Yeah, it does. I am going to have to look to see if can find a better stand
alone server to do this instead of patching django.

Vitaly Babiy


On Mon, Feb 9, 2009 at 12:22 AM, Alex Gaynor  wrote:

>
>
> On Mon, Feb 9, 2009 at 12:18 AM, Vitaly Babiy  wrote:
>
>> Yea, but I see a few problems whit that solution:
>>
>>- Hacky
>>- Still not guaranteed to work( it could take more time)
>>- Would really slow down the tests
>>
>> Vitaly Babiy
>>
>>
>> On Mon, Feb 9, 2009 at 12:15 AM, Alex Gaynor wrote:
>>
>>>
>>>
>>> On Mon, Feb 9, 2009 at 12:13 AM, Vitaly Babiy wrote:
>>>
 Right the problem is if I reload the server on ever test, there is not
 enough time for the thread to kill the server. So when the next setUp comes
 around the port is still in use.
 I think I need to find a way to start a HTTP server at the beginning of
 the test and keep it around till all test are done. And have a way to tell
 the server what to return on the request.

 Vitaly Babiy


 On Mon, Feb 9, 2009 at 12:08 AM, Alex Gaynor wrote:

>
>
> On Mon, Feb 9, 2009 at 12:06 AM, Vitaly Babiy wrote:
>
>> Hello everyone,
>>
>> I am working on a project that will need to make a request out to the
>> web and pull down some data, For testing purpose I was wonder what would 
>> be
>> the best way to test this. I don't want to make the actual request during
>> the test, because for one if I am off-line all those tests will fail.
>>
>> I have tried to implement a HTTPServer in python. The problem I am
>> having is once I have it thread, If I put it in the setUp method  and
>> tearDown I get port in use exception. Due to the nature of the thread it 
>> is
>> not guaranteed to be killed in time.
>>
>> Vitaly Babiy
>>
>>
>>
> You should be able to save the thread on the Test object during setup()
> and then kill it on teardown() shouldn't you?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
>
>



>>> What if you just put a time.sleep(2) at the end of tearDown() that should
>>> give the thread enough time to close before the next test starts.
>>>
>>>
>>> Alex
>>>
>>> --
>>> "I disapprove of what you say, but I will defend to the death your right
>>> to say it." --Voltaire
>>> "The people's good is the highest law."--Cicero
>>>
>>>
>>>
>>
>>
>>
> Is what you are ultimately searching for similar to this:
> http://code.djangoproject.com/ticket/2879
>
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Django and HTTP Request

2009-02-08 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 12:18 AM, Vitaly Babiy  wrote:

> Yea, but I see a few problems whit that solution:
>
>- Hacky
>- Still not guaranteed to work( it could take more time)
>- Would really slow down the tests
>
> Vitaly Babiy
>
>
> On Mon, Feb 9, 2009 at 12:15 AM, Alex Gaynor wrote:
>
>>
>>
>> On Mon, Feb 9, 2009 at 12:13 AM, Vitaly Babiy  wrote:
>>
>>> Right the problem is if I reload the server on ever test, there is not
>>> enough time for the thread to kill the server. So when the next setUp comes
>>> around the port is still in use.
>>> I think I need to find a way to start a HTTP server at the beginning of
>>> the test and keep it around till all test are done. And have a way to tell
>>> the server what to return on the request.
>>>
>>> Vitaly Babiy
>>>
>>>
>>> On Mon, Feb 9, 2009 at 12:08 AM, Alex Gaynor wrote:
>>>


 On Mon, Feb 9, 2009 at 12:06 AM, Vitaly Babiy wrote:

> Hello everyone,
>
> I am working on a project that will need to make a request out to the
> web and pull down some data, For testing purpose I was wonder what would 
> be
> the best way to test this. I don't want to make the actual request during
> the test, because for one if I am off-line all those tests will fail.
>
> I have tried to implement a HTTPServer in python. The problem I am
> having is once I have it thread, If I put it in the setUp method  and
> tearDown I get port in use exception. Due to the nature of the thread it 
> is
> not guaranteed to be killed in time.
>
> Vitaly Babiy
>
>
>
 You should be able to save the thread on the Test object during setup()
 and then kill it on teardown() shouldn't you?

 Alex

 --
 "I disapprove of what you say, but I will defend to the death your right
 to say it." --Voltaire
 "The people's good is the highest law."--Cicero



>>>
>>>
>>>
>> What if you just put a time.sleep(2) at the end of tearDown() that should
>> give the thread enough time to close before the next test starts.
>>
>>
>> Alex
>>
>> --
>> "I disapprove of what you say, but I will defend to the death your right
>> to say it." --Voltaire
>> "The people's good is the highest law."--Cicero
>>
>>
>>
>
> >
>
Is what you are ultimately searching for similar to this:
http://code.djangoproject.com/ticket/2879

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Django and HTTP Request

2009-02-08 Thread Vitaly Babiy
Yea, but I see a few problems whit that solution:

   - Hacky
   - Still not guaranteed to work( it could take more time)
   - Would really slow down the tests

Vitaly Babiy


On Mon, Feb 9, 2009 at 12:15 AM, Alex Gaynor  wrote:

>
>
> On Mon, Feb 9, 2009 at 12:13 AM, Vitaly Babiy  wrote:
>
>> Right the problem is if I reload the server on ever test, there is not
>> enough time for the thread to kill the server. So when the next setUp comes
>> around the port is still in use.
>> I think I need to find a way to start a HTTP server at the beginning of
>> the test and keep it around till all test are done. And have a way to tell
>> the server what to return on the request.
>>
>> Vitaly Babiy
>>
>>
>> On Mon, Feb 9, 2009 at 12:08 AM, Alex Gaynor wrote:
>>
>>>
>>>
>>> On Mon, Feb 9, 2009 at 12:06 AM, Vitaly Babiy wrote:
>>>
 Hello everyone,

 I am working on a project that will need to make a request out to the
 web and pull down some data, For testing purpose I was wonder what would be
 the best way to test this. I don't want to make the actual request during
 the test, because for one if I am off-line all those tests will fail.

 I have tried to implement a HTTPServer in python. The problem I am
 having is once I have it thread, If I put it in the setUp method  and
 tearDown I get port in use exception. Due to the nature of the thread it is
 not guaranteed to be killed in time.

 Vitaly Babiy



>>> You should be able to save the thread on the Test object during setup()
>>> and then kill it on teardown() shouldn't you?
>>>
>>> Alex
>>>
>>> --
>>> "I disapprove of what you say, but I will defend to the death your right
>>> to say it." --Voltaire
>>> "The people's good is the highest law."--Cicero
>>>
>>>
>>>
>>
>>
>>
> What if you just put a time.sleep(2) at the end of tearDown() that should
> give the thread enough time to close before the next test starts.
>
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Django and HTTP Request

2009-02-08 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 12:13 AM, Vitaly Babiy  wrote:

> Right the problem is if I reload the server on ever test, there is not
> enough time for the thread to kill the server. So when the next setUp comes
> around the port is still in use.
> I think I need to find a way to start a HTTP server at the beginning of the
> test and keep it around till all test are done. And have a way to tell the
> server what to return on the request.
>
> Vitaly Babiy
>
>
> On Mon, Feb 9, 2009 at 12:08 AM, Alex Gaynor wrote:
>
>>
>>
>> On Mon, Feb 9, 2009 at 12:06 AM, Vitaly Babiy  wrote:
>>
>>> Hello everyone,
>>>
>>> I am working on a project that will need to make a request out to the web
>>> and pull down some data, For testing purpose I was wonder what would be the
>>> best way to test this. I don't want to make the actual request during the
>>> test, because for one if I am off-line all those tests will fail.
>>>
>>> I have tried to implement a HTTPServer in python. The problem I am having
>>> is once I have it thread, If I put it in the setUp method  and tearDown I
>>> get port in use exception. Due to the nature of the thread it is not
>>> guaranteed to be killed in time.
>>>
>>> Vitaly Babiy
>>>
>>>
>>>
>> You should be able to save the thread on the Test object during setup()
>> and then kill it on teardown() shouldn't you?
>>
>> Alex
>>
>> --
>> "I disapprove of what you say, but I will defend to the death your right
>> to say it." --Voltaire
>> "The people's good is the highest law."--Cicero
>>
>>
>>
>
> >
>
What if you just put a time.sleep(2) at the end of tearDown() that should
give the thread enough time to close before the next test starts.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Working with URL Fields in django test.

2009-02-08 Thread Vitaly Babiy
Hello,

If I am using a URLField in form and it set to verify the URL, if I write
tests for the code and in the post I push a url like *http:google.com *it
will fail if the computer is off-line. Is there a good fix for this?

Vitaly Babiy

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Django and HTTP Request

2009-02-08 Thread Vitaly Babiy
Right the problem is if I reload the server on ever test, there is not
enough time for the thread to kill the server. So when the next setUp comes
around the port is still in use.
I think I need to find a way to start a HTTP server at the beginning of the
test and keep it around till all test are done. And have a way to tell the
server what to return on the request.

Vitaly Babiy


On Mon, Feb 9, 2009 at 12:08 AM, Alex Gaynor  wrote:

>
>
> On Mon, Feb 9, 2009 at 12:06 AM, Vitaly Babiy  wrote:
>
>> Hello everyone,
>>
>> I am working on a project that will need to make a request out to the web
>> and pull down some data, For testing purpose I was wonder what would be the
>> best way to test this. I don't want to make the actual request during the
>> test, because for one if I am off-line all those tests will fail.
>>
>> I have tried to implement a HTTPServer in python. The problem I am having
>> is once I have it thread, If I put it in the setUp method  and tearDown I
>> get port in use exception. Due to the nature of the thread it is not
>> guaranteed to be killed in time.
>>
>> Vitaly Babiy
>>
>>
>>
> You should be able to save the thread on the Test object during setup() and
> then kill it on teardown() shouldn't you?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Django and HTTP Request

2009-02-08 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 12:06 AM, Vitaly Babiy  wrote:

> Hello everyone,
>
> I am working on a project that will need to make a request out to the web
> and pull down some data, For testing purpose I was wonder what would be the
> best way to test this. I don't want to make the actual request during the
> test, because for one if I am off-line all those tests will fail.
>
> I have tried to implement a HTTPServer in python. The problem I am having
> is once I have it thread, If I put it in the setUp method  and tearDown I
> get port in use exception. Due to the nature of the thread it is not
> guaranteed to be killed in time.
>
> Vitaly Babiy
>
> >
>
You should be able to save the thread on the Test object during setup() and
then kill it on teardown() shouldn't you?

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Testing Django and HTTP Request

2009-02-08 Thread Vitaly Babiy
Hello everyone,

I am working on a project that will need to make a request out to the web
and pull down some data, For testing purpose I was wonder what would be the
best way to test this. I don't want to make the actual request during the
test, because for one if I am off-line all those tests will fail.

I have tried to implement a HTTPServer in python. The problem I am having is
once I have it thread, If I put it in the setUp method  and tearDown I get
port in use exception. Due to the nature of the thread it is not guaranteed
to be killed in time.

Vitaly Babiy

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem with simple shopping cart

2009-02-08 Thread lnysrogh

Thank you so much. That helped a lot. Such a simple mistake.

I've got some other questions now. My "add to cart" code:

def add(request, product_id):
added = (Product.objects.get(id=product_id), 1) # '1' is quantity
request.session.set_test_cookie()
if request.session.test_cookie_worked():
request.session.delete_test_cookie()
if 'cart' in request.session:
if added in request.session['cart']:
request.session['cart'][1] += 1
else:
request.session['cart'].append(added)
else:
request.session['cart'] = []
request.session['cart'].append(added)
return HttpResponseRedirect('/cart/')
else:
return HttpResponse('You need to enable cookies')

The code worked until I tried to check if the product is already
stored in the cart and to add 1 to the quantity instead of storing it
again. I'm getting this error: "can only concatenate tuple (not "int")
to tuple". What am I doing wrong?

Also, Andrew, I tried storing only the product id in the session
instead of the product object, and calling it in the show cart page.
Removing the "quantity" part of my code to simplify since it's not
working, I tried this:

Using the code above, I stored just the product_id in added, not the
Product.objects.get(id).

def cart(request):
if 'cart' in request.session:
cart = request.session['cart']
for item in cart:
cart = Product.objects.get(id=item)
return render_to_response('cart.html', {'cart': cart})
else:
return HttpResponse('Nenhum produto')

I get this: "int() argument must be a string or a number, not
'tuple'".

It seems there is one concept I'm not getting right, since I'm getting
similar error messages for totally different problems.

Any help?

Thanks.

On Feb 2, 10:14 pm, Andrew Ingram  wrote:
> lnysrogh wrote:
> > Hello. I'm new to Django (and web development in general), and this is
> > my first post here. Hope someone can help me.
>
> > I'm trying to build a shopping cart, and my idea is to store the
> > product information (id and quantity) in a session when I add the
> > product to the shopping cart, and retrieve it to display in the "show
> > cart" page. I'm using sessions for this because I don't want the user
> > to have to log in or register just to add some items to the cart and
> > see the total price. When he logs in to actually buy something, I
> > pretend to store it in a cart model, but I didn't get there yet. I'll
> > show you the code I'm testing:
>
> > def add(request, product_id):
> >    request.session.set_test_cookie()
> >    if request.session.test_cookie_worked():
> >            request.session.delete_test_cookie()
> >            added = Product.objects.get(id=product_id)
> >            request.session['product_id'] = added
> >            return HttpResponseRedirect('/cart/')
> >    else:
> >            return HttpResponse('You need to enable cookies')
>
> > def cart(request):
> >    if 'product_id' in request.session:
> >            cart = request.session['product_id']
> >            return render_to_response('cart.html', {'cart': cart})
> >    else:
> >            return HttpResponse('Cart is empty')
>
> > That's what I was able to come up with. The first problem is, it's not
> > working. The second problem is, I can't figure out how to add more
> > than one product to the cart.
>
> > The error I'm getting when I add something to the cart is "Caught an
> > exception while rendering: 'Product' object is not iterable". I'm
> > pretty sure that error has something to do with the cart.html, because
> > if I replace that line with:
>
> > return HttpResponse('You've added the product %s to the cart' % cart)
>
> > it works. The cart.html is just this:
>
> > {% for product in cart %}
> > Your cart: {{ product.name }} - {{product.price}}
> > {% endfor %}
>
> > It should work, right? I just can't figure what's causing that error.
>
> I've noticed a few things that you should consider:
>
> Firstly, you're storing the actual product object in the session which
> is less than ideal, it'd be better to load any cart objects from the db
> at the start of each request. This prevents the problem of a session
> product and the real db product getting out of sync if a change is made.
>
> Second problem is that you're assigning request['product_id'] to an
> actual product, but when you're doing the lookup later you're treating
> it as if it is a list of products. When you think about it, it's clear
> why iterating over it isn't working.
>
> What I would do is have a Cart model which contains a set of Products (I
> tend to create a CartItem model as well for storing other info such as
> quantity). Normally you'd just save this to the 

Problem with set_language generic view

2009-02-08 Thread yav

Hello,

I have a problem with the generic view set_language. I used it but it
doesn't change the language. I have read the doc but I didn't find
what is the problem. I have read the doc but I didn't find what is the
problem. I have setup an empty project in order test it with a very
simple example. Here is my config: http://dpaste.com/hold/118420/.

I'm working with the latest svn version. I tested the application with
Safari and Firefox and with Apache and the development server, but it
doesn't work anyway.

Does anyone have a working example? Because all the examples I have
used don't work. Here is the test project in a zip file:
http://dl.getdropbox.com/u/576053/multi.zip

Regards,
Alberto

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: converting a string object into class object

2009-02-08 Thread Saurav

Thanks Daniel and Bruno, your tips were gr8. It helped me out a lot.

I am a newbie in python as well as Django, and I m trying to learn
them ASAP.
I had to finish some work quickly and so had pushed the question
here.

Thanks anyways

-Saurav


On Feb 6, 2:24 pm, bruno desthuilliers 
wrote:
> On 6 fév, 08:01,Saurav wrote:
>
> > Hi,
>
> > I want to know if its possible to convert a string object into class
> > object.
>
> I assume you mean "retrieve an existing class object by it's name".
>
> (snip)
>
> >http://dpaste.com/117323/
>
> > at line no 40,
>
> f = model_name.__name__+"Form"(instance=a)
>
> Won't work - str is not a callable type.
>
> > if you notice, I m trying to add "Form" to the
> > model_name for creating an instance of the class CompanyForm, here is
> > my problem, as a result of the addition it becomes string object
>
> Given that you are concatening two strings, you could hardly expect
> anything else than a string.
>
> Ok - first point, at line 33, you have:
>
>  # nb : until this point 'model_name' is a str
>  model_name = get_model('dashboard',model_name)
>
> get_model returns a class object (a Model subclass FWIW). Naming it
> "model_name" is a *very* poor choice. Name it 'model', or 'model_cls',
> or 'model_object', but please leave the original model_name alone.
>
> Now wrt/ your question: you can retrieve an object's attribute by name
> using the getattr(obj, name) function. Since module are objects and
> class objects are (usually) attributes of their module, if module
> "somemodule" defines class "SomeClass", you can do:
>
> import somemodule
> someclass = getattr(somemodule, "SomeClass")
>
> Also, if the object to retrieve by name actually lives in the current
> namespace, you can also retrieve it using a dict returned by globals()
> or locals(). In your case, since CompanyForm is defined in the same
> module, this is what you want.
>
> class Foo(object):
>     pass
>
> def bar():
>    cls = globals()['Foo']
>
> > and
> > hence im getting the error 'str' object is not callable'
>
> Obviously, yes.
>
> > How can I overcome this problem ??
>
> cf above.
>
> Also, taking time to learn Python (and eventually asking Python-
> related question in a Python-related newsgroup - like, for example,
> comp.lang.python) might be a good idea...
>
> HTH
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding project revision number to templates.

2009-02-08 Thread Dana Woodman
Thank you both! That is exactly what I was looking for!

Cheers


On Sun, Feb 8, 2009 at 3:34 PM, James Bennett  wrote:

>
> On Sun, Feb 8, 2009 at 5:21 PM, Russell Keith-Magee
>  wrote:
> > 1) Look at django.utils.version.get_svn_revision(). This method tells
> > you Django's SVN revision. Make a copy of this method and modify it to
> > point at your own code, telling you the version of your clients SVN
> > checkout.
>
> The second part actually isn't necessary; if you pass the first part
> of the module path (e.g., some_module.__path__[0]) as the keyword
> argument "path" to get_svn_revision(), it'll happily go hunt that down
> and calculate the SVN revision of that path rather than Django.
>
>
> --
> "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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pre-populating multiplechoicefields with session data

2009-02-08 Thread Bobby Roberts

anyone have any idea on 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Extending the User model

2009-02-08 Thread Patricio Palma

Yeah you're right
I can't believe that
I mix the admin settings in the class, for a short explanation.

my code:
---
models.py
from django.contrib.auth.models import User
class MyUser(User):
chilean_rut  = CLRutField(_('RUT'),primary_key=True)
some_field = models.CharField(max_length=50)

admin.py
class MyUserAdmin(admin.ModelAdmin):

list_display = ('chilean_rut', 'email','some_field')

admin.site.register(MyUser,MyUserAdmin)

-

And my list_display is EMPTY ( on the  http://127.0.0.1:8000/admin/myapp/myuser/
)

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Postgresql v MySQL

2009-02-08 Thread richr

Barry Pederson has nice, short example of adding PostgreSQL full text
search to an existing Djanog app at:

   http://barryp.org/blog/entries/postgresql-full-text-search-django/


On Feb 8, 11:22 am, Alex Gaynor  wrote:
> On Sun, Feb 8, 2009 at 11:20 AM, Petite Abeille 
> wrote:
>
>
>
>
>
>
>
> > On Feb 8, 2009, at 5:17 PM, Peter2108 wrote:
>
> > > Thanks. Between posting and your response I found out that MySQL
> > > has built in support for full-text searchs but PostgreSQL does not.
>
> > Hmmm...
>
> >http://www.postgresql.org/docs/8.3/static/textsearch.html
>
> > --
> > PA.
> >http://alt.textdrive.com/nanoki/
>
> Postgres has full text support from 8.3 onwards, however django doesn't have
> support for using it from within the ORM yet, 
> seehttp://code.djangoproject.com/ticket/3254
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero- Hide quoted text -
>
> - Show quoted text -

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Best practice question: subclassing external app components

2009-02-08 Thread zinckiwi

Hi folks,

I'm just starting to play with django-registration and I want to
subclass the RegistrationForm for a couple of cosmetic tweaks
(capitalising the labels on the fields -- there may be a simpler way
to do this, but indulge me for the purposes of this question). I
understand that subclassing RegistrationForm and reassigning the label
strings is the way to do this -- no problem.

My question is where to *put* that subclass. I can think of a few
places:

- the project itself
- an "overrides" app dedicated to holding overrides for external apps
- a "registration_overrides" app dedicated to holding overrides for
just that one external app

Perhaps there are other ways. Of these, I'm favouring #2. While #3 has
the virtue of being more portable, it seems like a lot of (logical)
overhead to perform a simple modification to another app.

So I guess I'd like to hear if there's an accepted way to do this, or
failing that, what anyone has found to work well (or what to avoid).

Thanks all,
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding project revision number to templates.

2009-02-08 Thread James Bennett

On Sun, Feb 8, 2009 at 5:21 PM, Russell Keith-Magee
 wrote:
> 1) Look at django.utils.version.get_svn_revision(). This method tells
> you Django's SVN revision. Make a copy of this method and modify it to
> point at your own code, telling you the version of your clients SVN
> checkout.

The second part actually isn't necessary; if you pass the first part
of the module path (e.g., some_module.__path__[0]) as the keyword
argument "path" to get_svn_revision(), it'll happily go hunt that down
and calculate the SVN revision of that path rather than Django.


-- 
"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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding project revision number to templates.

2009-02-08 Thread Russell Keith-Magee

On Mon, Feb 9, 2009 at 8:17 AM, Dana  wrote:
>
> Hi all,
>
> Wondering what the best approach would be to add my projects revision
> number to my projects admin? I would like to show the revision number
> of my SVNed project in my admin templates so I can easily see what
> version each client is running. How would one go about doing this?

Two steps:

1) Look at django.utils.version.get_svn_revision(). This method tells
you Django's SVN revision. Make a copy of this method and modify it to
point at your own code, telling you the version of your clients SVN
checkout.

2) Write a template context processor to insert that version number
into the context.

When you install the template context processor, the SVN revision will
become available to every template.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding project revision number to templates.

2009-02-08 Thread Dana

Hi all,

Wondering what the best approach would be to add my projects revision
number to my projects admin? I would like to show the revision number
of my SVNed project in my admin templates so I can easily see what
version each client is running. How would one go about doing this?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Traceback in the ``runserver`` console

2009-02-08 Thread rz

I too would like to have this functionality.  Has anyone opened a
ticket and/or started working on a patch?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Exception in Django's Exception Handling

2009-02-08 Thread Karen Tracey
On Sun, Feb 8, 2009 at 2:20 PM, Devel63  wrote:

>
> Django is raising an exception while trying to process an exception,
> resulting in no stack traces ... for many different types of errors.
>
> It has the problem in debug.py, at this line under
> technical_500_response:
>return HttpResponseServerError(t.render(c), mimetype='text/html')
>
> I have DEBUG=True, and TEMPLATE_DEBUG = DEBUG.  The situation arises
> for almost any error (undefined var, missing func arg, call to
> undefined member func, etc.), but in some cases it does actually
> generate a stack trace!
>

Ditto what Russ said: I've not seen this.  Your earlier note, which I had in
my list of things to go back to and try to answer when I had more time if no
one else responded, mentions you are using Google App Engine...does that
apply to what you are talking about here?  I've not done a lot with GAE, but
some,and I haven't seen this behavior there either -- I get regular Django
debug pages under GAE, though actually I'm only 100% sure of that when
running in the development environment, I don't know that I've tested it on
a deployed project.  So specifics of a small test case that demonstrates the
problem you are seeing would help track this down -- it doesn't seem to be
behavior people are seeing generally.

Karen

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



MySQLdb for Python 2.6 on win32

2009-02-08 Thread Technicalbard

If you are looking for this, I compiled it using MSVC++2008 Express,
against MySQL 5.0.67 using Python 2.6 and the MySQLdb 1.2.2 source:

http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe

Hope it helps anyone who was looking.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Exception in Django's Exception Handling

2009-02-08 Thread Russell Keith-Magee

On Mon, Feb 9, 2009 at 4:20 AM, Devel63  wrote:
>
> Django is raising an exception while trying to process an exception,
> resulting in no stack traces ... for many different types of errors.
>
> It has the problem in debug.py, at this line under
> technical_500_response:
>return HttpResponseServerError(t.render(c), mimetype='text/html')
>
> I have DEBUG=True, and TEMPLATE_DEBUG = DEBUG.  The situation arises
> for almost any error (undefined var, missing func arg, call to
> undefined member func, etc.), but in some cases it does actually
> generate a stack trace!
>
> Any ideas?

I can't say I've seen this before. The Django 500 handler hasn't
changed for some time, and I've always found it to be pretty robust.

If you're having problems, we'd like to address them, but it's
difficult to do so in an abstract sense - we really need a concrete
example that fails. The easiest way to do this is to take the example
that is broken, and start cutting things out until you are left with
the minimal possible example that still exhibits the problem. Once you
have a minimal project (probably something like a single view that
crashes under certain input conditions), send that to us along with
your environment (OS, Python and Django version) and we can try to
replicate the problem and work what is going on.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Extending the User model

2009-02-08 Thread Karen Tracey
On Sun, Feb 8, 2009 at 5:33 PM, Patricio Palma wrote:

>
> At revision 9820.
>
> ???
>

??? indeed.  What doc are you reading that suggests having  something like
"admin = meta.Admin(..." under class Meta of your model definition?  I've
never seen anything like it but I've only been around since 0.96 or so and
others seem to recognize it as very old syntax from earlier releases.  If
you were running r9820 I'd expect you to get a NameError on that line since
there's nothing named meta to support that call.

The current way to set list_display, if you are running 1.0 or more recent,
is documented here:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-options

The admin defs are all now included in ModelAdmin classes, there is no more
admin definition tied into the model class definition itself.  But if you
were running a relatively recent Django, I'd expect you'd be seeing errors
with the code you are showing us, so I am rather confused by your report of
no errors, just not the results you were expecting.

Karen

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



Re: Extending the User model

2009-02-08 Thread Patricio Palma

At revision 9820.

???

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Extending the User model

2009-02-08 Thread Daniel Roseman

On Feb 8, 9:06 pm, Patricio Palma  wrote:
> > This code looks exceptionally old, admin = meta.Admin() has been gone for
> > several years, what version of django are you workign with?
>
> 1.1 pre-alpha
> I 've in admin.py file, the main idea was show the list_display field
> setted

That's impossible. This code is from version 0.90, maybe even older.
It just wouldn't work on 1.1.
--
DR.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding fields to model objects that don't correspond to database state

2009-02-08 Thread Alex Koshelev
try this:

def attach_bar(self, bar):
  if getattr(self, "bars", None) is None:
  self.bars = []
  self.bars.append(bar)


On Mon, Feb 9, 2009 at 12:03 AM, Jack Orenstein  wrote:

>
> I have a model object that looks something like this:
>
>   class Foo(models.Model)
>   foo_id = models.IntegerField(primary_key = True)
>   xyz = models.CharField(max_length = 20)
>
> In my application, I'd like to add a list of Bar objects. It's like a
> foreign key, except that Bar objects don't exist in my databases. So
> I want a Foo.bars field.
>
> - If I just create the field:
>
>   class Foo(models.Model)
>   foo_id = models.IntegerField(primary_key = True)
>   xyz = models.CharField(max_length = 20)
>   bars = []
>
> Then the list belongs to the class, not instances.
>
> - If I try creating the field lazily, e.g.
>
>   class Foo(models.Model)
>   foo_id = models.IntegerField(primary_key = True)
>   xyz = models.CharField(max_length = 20)
>
>   def attach_bar(self, bar):
>   if self.bars is None:
>   self.bars = []
>   self.bars.append(bar)
>
> Then calling attach_bar from the application results in an
> AttributeError, 'Foo' object has no attribute 'bars'.
>
> - Specifying Foo.__init__ to initialize bars doesn't work, because it
> interferes with creation of Foo objects from database queries.
>
> I played around with subclassing, e.g. class FooBase
> (models.Model) ... class Foo(FooBase) but couldn't get that to work.
>
> How can I add a field to the Foo class that doesn't come from the
> database?
>
> Jack Orenstein
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Extending the User model

2009-02-08 Thread Patricio Palma


> This code looks exceptionally old, admin = meta.Admin() has been gone for
> several years, what version of django are you workign with?
>

1.1 pre-alpha
I 've in admin.py file, the main idea was show the list_display field
setted
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding fields to model objects that don't correspond to database state

2009-02-08 Thread Jack Orenstein

I have a model object that looks something like this:

   class Foo(models.Model)
   foo_id = models.IntegerField(primary_key = True)
   xyz = models.CharField(max_length = 20)

In my application, I'd like to add a list of Bar objects. It's like a  
foreign key, except that Bar objects don't exist in my databases. So  
I want a Foo.bars field.

- If I just create the field:

   class Foo(models.Model)
   foo_id = models.IntegerField(primary_key = True)
   xyz = models.CharField(max_length = 20)
   bars = []

Then the list belongs to the class, not instances.

- If I try creating the field lazily, e.g.

   class Foo(models.Model)
   foo_id = models.IntegerField(primary_key = True)
   xyz = models.CharField(max_length = 20)

   def attach_bar(self, bar):
   if self.bars is None:
   self.bars = []
   self.bars.append(bar)

Then calling attach_bar from the application results in an  
AttributeError, 'Foo' object has no attribute 'bars'.

- Specifying Foo.__init__ to initialize bars doesn't work, because it  
interferes with creation of Foo objects from database queries.

I played around with subclassing, e.g. class FooBase 
(models.Model) ... class Foo(FooBase) but couldn't get that to work.

How can I add a field to the Foo class that doesn't come from the  
database?

Jack Orenstein

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Extending the User model

2009-02-08 Thread Patricio Palma

Greetings

I've a model
class MyUser(auth.User):
location = meta.CharField(maxlength=100, blank=True)

class META:
replaces_module = 'auth.users'
admin = meta.Admin(
list_display = ('username', 'email',
'first_name','last_name', 'lacation')
)


looks fine, but, after add a new myUser (successfully) my user list
it's empty

just like a list_display = ('')

what is wrong?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to detect inactivity session time out?

2009-02-08 Thread ydjango

I am setting inactivity session time out using -
 a)  request.session.set_expiry(900) and
b)  SESSION_COOKIE_AGE = 900

I believe both work exactly the same way. Please correct me if they
have any different behavior.

How do I detect this time out in my app and give user a page that they
have been timed out due to inactivity.
I am using django standard authentication using autheticate(), login()
and logout()



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python and import path

2009-02-08 Thread Bradley Wright

On Feb 8, 4:25 pm, Jeff  wrote:
> I actually got it to work by changing the PYTHONPATH from '/var/www/
> django/legend' to just '/var/www/django'.  Not sure if this is only
> due to my version of python or what.  But thank you for the help.

It's because Python tries to look inside the directories/modules in
PYTHONPATH. So it was actually looking for:

/var/www/django/legend/legend

which obviously doesn't exist.

Glad it's working 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Extending the User model

2009-02-08 Thread Alex Gaynor
On Sun, Feb 8, 2009 at 3:06 PM, Patricio Palma wrote:

>
> Greetings
>
> I have a model
>
> from django.contrib.auth.models import User
> class MyUser(User):
>
>chilean_rut  = CLRutField(_('RUT'),primary_key=True)
>
>class Meta:
>
>   admin = meta.Admin(
>fields = (
>(_('Personal info'), {'fields': ('first_name', 'last_name',
> 'chilean_rut','email')}),
>(_('Extended info'), {'fields': ('gamename', 'url',
> 'description')}),
>(_('Permissions'), {'fields': ('is_staff', 'is_active',
> 'is_superuser', 'user_permissions')}),
>(_('Important dates'), {'fields': ('last_login',
> 'date_joined')}),
>(_('Groups'), {'fields': ('groups',)}),
>),
>list_display = ('username', 'gamename', 'first_name',
> 'last_name', 'is_staff'),
>
> looks fine, but in my users list after added, I see only the total of
> added users
>
> just like list_display was empty
>
>
> Thanks
>
> >
>
This code looks exceptionally old, admin = meta.Admin() has been gone for
several years, what version of django are you workign with?

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Extending the User model

2009-02-08 Thread Patricio Palma

Greetings

I have a model

from django.contrib.auth.models import User
class MyUser(User):

chilean_rut  = CLRutField(_('RUT'),primary_key=True)

class Meta:

   admin = meta.Admin(
fields = (
(_('Personal info'), {'fields': ('first_name', 'last_name',
'chilean_rut','email')}),
(_('Extended info'), {'fields': ('gamename', 'url',
'description')}),
(_('Permissions'), {'fields': ('is_staff', 'is_active',
'is_superuser', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login',
'date_joined')}),
(_('Groups'), {'fields': ('groups',)}),
),
list_display = ('username', 'gamename', 'first_name',
'last_name', 'is_staff'),

looks fine, but in my users list after added, I see only the total of
added users

just like list_display was empty


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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Postgresql v MySQL

2009-02-08 Thread AmanKow

I started with mysql and moved to postgres.  My main reasons:

1) If you ever need to dumpdata/loaddata, you may find that postgres
(correctly) defers checking of fk constraints until after the a
transaction is complete.  MySQL checks the constraints as each record
is added, even inside of a transaction.  This can break a dump/load
cycle, requiring a manual reordering of records in the fixture.  And
can make circular references impossible to deal with at all.

2) Postgres transactions can wrap table altering, creation and
deletion.  MySQL cannot.  This is essential if you want sane, safe
migrations.

I found Postgres  a bit more difficult to get going, but not
appreciably so.  After the small amount of additional pain, it has
been rock solid.  pgadmin works quite well for administration tasks.

So, unless my hand is forced in some way, I find postgres a better
choice than mysql.

Wayne
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Exception in Django's Exception Handling

2009-02-08 Thread Devel63

Django is raising an exception while trying to process an exception,
resulting in no stack traces ... for many different types of errors.

It has the problem in debug.py, at this line under
technical_500_response:
return HttpResponseServerError(t.render(c), mimetype='text/html')

I have DEBUG=True, and TEMPLATE_DEBUG = DEBUG.  The situation arises
for almost any error (undefined var, missing func arg, call to
undefined member func, etc.), but in some cases it does actually
generate a stack trace!

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



Re: Admin site not using my overridden save()?

2009-02-08 Thread Silfheed

Arrrg.  Ok, so all typo's fixed, the code does work correctly... so
there must be a rogue try except block out there intercepting errors
and not sending them on to my logger.  Thanks

On Feb 6, 7:38 am, Karen Tracey  wrote:
> On Thu, Feb 5, 2009 at 2:08 PM, Silfheed  wrote:
>
> > No, not a direct cut and paste (I guess I should have)
>
> > class person(models.Model):
> >    gender = models.CharField(max_length=1, choices=(('M','male'),
> > ('F','female')))
> >    other = models.CharField(manx_length=20, null=True,blank=True)
>
> >    def save(self, force_insert=False, force_update=False):
> >        if 'M' == self.gender:
> >            self.other = 'Manly Man'
> >        else:
> >            self.other = 'Womanly Woman'
>
> >        super(person, self).save(force_insert, force_update
>
> > The save works fine from the ./manage.py shell.  It's only when I use
> > the admin page to add or create a person that it doesnt work.  Am I
> > supposed to set up a form and use a form_save() as well or is the
> > above look correct?
>
> The above works, once the missing close paren is added and manx_length is
> changed to max_length on the 'other' field.  I cut-and-pasted what you have
> into a test project, made those changes,  and registered person with the
> admin.  Then, when I add a person in the admin, the other field is set
> properly based on the gender value.  So, I am not sure what is going on with
> your setup.  The fact that you are not having trouble with manx_length
> suggests maybe this code is not actually the code being used when you are
> testing?
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Anyone hosting Django based site/app on EC2?

2009-02-08 Thread ydjango

Is anyone hosting their Django based site with Mysql db on Amazon ec2?

How has been your experience in terms of
1) Cost (pay for what you use versus dedicated server model).
2) Scaling
3) Maintenance effort needed
4) Load balancing and fail over
5) Reliability


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



pre-populating multiplechoicefields with session data

2009-02-08 Thread Bobby Roberts

Hi group.  Please look at this view:

# this form runs the search mechanism
def DoSearchForm (request):
if request.method =='POST':
form=SearchForm (request.POST)
if form.is_valid():
try:
myuid=request.user.id * 1
except:
myuid=0
#form submitted passes validation so submit to database as
a valid search term record
mydata = SearchAttempt (
Terms = CleanMe(request.POST.get('Terms','')),
suid = myuid
)
mydata.save()   #save to sarch_attempt table
# save items to session variables
request.session["Terms"]=request.POST.get('Terms','')
request.session["Iforand"]=request.POST.get('Iforand','')
request.session["Programelement"]=request.POST.get
('Programelement','')
request.session["Disaster"]=request.POST.get
('Disaster','')
request.session["Submissionmethod"]=request.POST.get
('Submissionmethod','')

return HttpResponseRedirect('/search/results/')
else:
return render_to_response('submit-search.html', {'form':
form}, context_instance=RequestContext(request))
else:# load form for first time
if 'Terms' in request.session:
form = SearchForm(initial={'Terms':request.session
['Terms'],'Iforand':request.session
['Iforand'],'Programelement':request.session
['Programelement'],'Disaster':request.session
['Disaster'],'Submissionmethod':request.session['Submissionmethod']})
else:
form = SearchForm(initial={'Iforand':'exact'})
return render_to_response('submit-search.html', {'form':
form}, context_instance=RequestContext(request))


This view is working perfectly except for one thing.  If someone
completes the form, it saves the form options to a session and inserts
the term they searched for into the database.  If they close their
browser and come back to the search form, I want their previous
choices to populate the form again.  Terms and Iforand populate as
they should.  Programelement, Disaster, and Submissionmethod are all
multiplechoicefield textbox lists and none of the previously selected
options are selected.  Can you see what i'm 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin "Documentation" link not visible

2009-02-08 Thread Alex Gaynor
On Sun, Feb 8, 2009 at 12:32 PM, adrian  wrote:

>
>
> The doc under "Using the built-in reference" says:
>
>  Django's admin interface includes a complete reference of all
> template tags and filters available
>  for a given site. To see it, go to your admin interface and click
> the "Documentation" link in the
>  upper right of the page.
>
> But I don't have that link - is there some configuration necessary to
> see it or that could be hiding it?
> I am using Pinax otherwise standard Django 1.0.2.
>
> Thanks
> >
>
Yes you need to have 'django.contrib.admindocs'  and have the urls wired
up(you should just need to uncomment it from the default urls.py).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



admin "Documentation" link not visible

2009-02-08 Thread adrian


The doc under "Using the built-in reference" says:

  Django's admin interface includes a complete reference of all
template tags and filters available
  for a given site. To see it, go to your admin interface and click
the "Documentation" link in the
  upper right of the page.

But I don't have that link - is there some configuration necessary to
see it or that could be hiding it?
I am using Pinax otherwise standard Django 1.0.2.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Postgresql v MySQL

2009-02-08 Thread Justin Bronn

On Feb 7, 8:06 am, Tim Chase  wrote:
> PostgreSQL has built-in GIS data-types and functions, which I
> believe are required for theGeoDjangofunctionality (or Oracle).
>   PG also allows flexible creation of new data-types and
> functions/operators as shown by the GIS data-types that were
> integrated early.  It also offers some under-the-covers stunts
> with table-inheritance.  It's very close to Oracle syntax (from
> what I understand, having never used Oracle), so Oracle admins
> may feel more at home in PG.

Just a correction here -- MySQL actually has the GIS types built-in,
whereas with Postgres you have to install the PostGIS extension.
However, the PostGIS types and functions are feature-complete and
compliant with the relevant GIS standards, whereas the built-in MySQL
implementation is half-baked and non-compliant (e.g., no spatial
indexes on InnoDB tables, MBR-only functions, no distance
calculations).

> I personally find MySQL easier to administer, but MySQL has a
> reputation as being built for developers, while PosgreSQL has a
> reputation as being built for DBAs.  I'm a developer first.

I was once a MySQL user, but quite frankly I've become quite alarmed
at MySQL's attitude towards data integrity -- I just don't totally
trust it anymore.  With two botched releases in a row containing
critical bugs (5.0 and 5.1), my impression hasn't improved.  I'm a
developer who cares about his and his client's data first.

> So I can't really recommend one vs. the other unless I knew your
> needs.  Do you needGeoDjango, custom data-types,
> table-inheritance or "enterprise"y features for your DBA, then
> PostgreSQL may be a better choice.  Do you need flexibility in
> storage-engine choice, ready availability on shared/inexpensive
> web hosts, or spiffy GUI/web admin interfaces, then use MySQL.

There's also pgAdmin III, a GUI interface available for PostgreSQL,
and installed by default with the windows installers.

Regardless, I second the opinion to develop for both so one can make
their own judgment to which best suits their needs.

Regards,
-Justin


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python and import path

2009-02-08 Thread Jeff

On Feb 8, 9:52 am, Karen Tracey  wrote:
> On Sun, Feb 8, 2009 at 9:44 AM, Jeff  wrote:
> > On Feb 8, 4:29 am, Bradley Wright  wrote:>
> > > And if you're really using mod_python already with Apache, also post
> > > your vhost file.
> > vhost file:
> > #Block conf
> > files###
> > 
> >    Order allow,deny
> >    Deny from all
> > 
> > #Django
> > mod_python###
> > 
> >    SetHandler python-program
> >    PythonHandler django.core.handlers.modpython
> >    SetEnv DJANGO_SETTINGS_MODULE legend.settings
> >    PythonOption django.root /legend
> >    PythonDebug On
> >    PythonPath "['/var/www/django/legend'] + sys.path"
> > 
>
> You've got the same problem with duplicating 'legend' in your
> DJANGO_SETTINGS_MODULE spec and PythonPath spec as the poster in this
> thread:
>
> http://groups.google.com/group/django-users/msg/e8411403c00de3f6
>
> had duplicating 'mysite', and you have the same options for fixing it as I
> described there.
>
> Karen

I actually got it to work by changing the PYTHONPATH from '/var/www/
django/legend' to just '/var/www/django'.  Not sure if this is only
due to my version of python or what.  But thank you for the help.

Jeff
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Postgresql v MySQL

2009-02-08 Thread Alex Gaynor
On Sun, Feb 8, 2009 at 11:20 AM, Petite Abeille wrote:

>
>
> On Feb 8, 2009, at 5:17 PM, Peter2108 wrote:
>
> > Thanks. Between posting and your response I found out that MySQL
> > has built in support for full-text searchs but PostgreSQL does not.
>
> Hmmm...
>
> http://www.postgresql.org/docs/8.3/static/textsearch.html
>
> --
> PA.
> http://alt.textdrive.com/nanoki/
>
>
> >
>
Postgres has full text support from 8.3 onwards, however django doesn't have
support for using it from within the ORM yet, see
http://code.djangoproject.com/ticket/3254

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Postgresql v MySQL

2009-02-08 Thread Petite Abeille


On Feb 8, 2009, at 5:17 PM, Peter2108 wrote:

> Thanks. Between posting and your response I found out that MySQL
> has built in support for full-text searchs but PostgreSQL does not.

Hmmm...

http://www.postgresql.org/docs/8.3/static/textsearch.html

--
PA.
http://alt.textdrive.com/nanoki/


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Postgresql v MySQL

2009-02-08 Thread Peter2108

Thanks. Between posting and your response I found out that MySQL
has built in support for full-text searchs but PostgreSQL does not.
But Django seems
as happy with the one as the other.

-- Peter

On Feb 7, 2:06 pm, Tim Chase  wrote:
> > Is there any clear reason for preferring one of these DBMS over the
> > other for use with Django (1.0 onwards).
>
> Historically, PostgreSQL has favored correctness, ANSI standards,
> and data-integrity while MySQL has favored speed and
> pluggability.  For the most part, they've reached equilibrium.
>
> The GUI/web admin tools are also a bit more polished and diverse
> compared to the PostgreSQL tools.  I just use the command-line
> client for most administration, so it's not a big deal to me.
>
> As of some very old stats I've seen (and thus likely invalid),
> MySQL handled higher initial loads, but wasn't able to sustain
> them as gracefully; while PostgreSQL kept up with traffic, even
> if initial request response-times were a wee bit slower than
> MySQL.  (MySQL had better performance until it reached a
> threshold and then started falling off; while PostgreSQL's didn't
> experience the same falling-off under high load).  Take this with
> a grain of salt as I mention, since the study was c. 2003 or
> something.  A lot happens in 5 years. :)
>
> There are a couple distinguishing features offered by one that
> you won't find in the other such as:
>
> MySQL is more popularly installed on cheaper shared-hosting
> plans, so you'll find it more in the wild. It's also possible to
> use various table-types ("storage engines" in MySQL-speak[1])
> which may not offer transaction safety, but offer other benefits:
>   memory-only tables, "Merged" tables which can be split across
> drives, MyISAM tables which are faster but don't offer
> transactions, and "archive" tables which are good for
> infrequently accessed ("archived", duh :) data.
>
> PostgreSQL has built-in GIS data-types and functions, which I
> believe are required for the GeoDjango functionality (or Oracle).
>   PG also allows flexible creation of new data-types and
> functions/operators as shown by the GIS data-types that were
> integrated early.  It also offers some under-the-covers stunts
> with table-inheritance.  It's very close to Oracle syntax (from
> what I understand, having never used Oracle), so Oracle admins
> may feel more at home in PG.
>
> I personally find MySQL easier to administer, but MySQL has a
> reputation as being built for developers, while PosgreSQL has a
> reputation as being built for DBAs.  I'm a developer first.
>
> So I can't really recommend one vs. the other unless I knew your
> needs.  Do you need GeoDjango, custom data-types,
> table-inheritance or "enterprise"y features for your DBA, then
> PostgreSQL may be a better choice.  Do you need flexibility in
> storage-engine choice, ready availability on shared/inexpensive
> web hosts, or spiffy GUI/web admin interfaces, then use MySQL.
>
> My last bit of advice:  if you don't care strongly about any of
> these features, DEVELOP FOR BOTH -- they're both free to download
> and install, so there's little reason not to.  Django
> (particularly the work on the ORM -- special thanks to Malcolm
> here) makes this very easy.  You can then test against both and
> see which performs better.  And if it's an app you plan to share,
> it will let others choose a backing DB for their own reasons
> rather than reasons foisted by you.
>
> -tim
>
> [1]http://dev.mysql.com/doc/refman/5.1/en/storage-engines.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



DHTML Grid

2009-02-08 Thread Manoj

Hello,

I need to dynamically add rows to table similar to what has been done
in http://dhtmlgrid.sourceforge.net/debug/demo.htm. This code was
released in 2003 i wonder do we have code that i can use in my
project.

I am not sure about the robustness of the code.

Thanks in advance.
Regards,
Manoj

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python and import path

2009-02-08 Thread Karen Tracey
On Sun, Feb 8, 2009 at 9:44 AM, Jeff  wrote:

> On Feb 8, 4:29 am, Bradley Wright  wrote:>
> > And if you're really using mod_python already with Apache, also post
> > your vhost file.
> vhost file:
> #Block conf
> files###
> 
>Order allow,deny
>Deny from all
> 
> #Django
> mod_python###
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE legend.settings
>PythonOption django.root /legend
>PythonDebug On
>PythonPath "['/var/www/django/legend'] + sys.path"
> 
>

You've got the same problem with duplicating 'legend' in your
DJANGO_SETTINGS_MODULE spec and PythonPath spec as the poster in this
thread:

http://groups.google.com/group/django-users/msg/e8411403c00de3f6

had duplicating 'mysite', and you have the same options for fixing it as I
described there.

Karen

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



Re: mod_python and import path

2009-02-08 Thread Jeff


On Feb 8, 4:29 am, Bradley Wright  wrote:
> On Feb 8, 4:39 am, Jeff  wrote:
>
> > I installed django today and have not been able to get it to work with
> > apache, or itself really.  I have the path in the sys.path and have
> > set the settings module to point to it, but it cannot find it.  It
> > works fine when I use 'python manage.py shell' or 'python manage.py
> > validate' but when I export the environment settings, the 'django-
> > admin.py validate' throws an error saying its not in the sys.path or
> > isn't valid.
>
> Could you please post:
> - The directory your Django project is in;
Django Project Directory:
'/var/www/django/legend/'

> - The directory Django itself is in; and
Django Directory:
'/usr/lib/python2.3/site-packages/django/__init__.pyc'

> - The output from the following command:
> python -c "import sys; print sys.path"
sys.path output:
['', '/usr/lib/python2.3/site-packages/MySQL_python-1.2.2-py2.3-linux-
i686.egg', '/usr/lib/python2.3/site-packages/ClientCookie-1.3.0-
py2.3.egg', '/usr/lib/python2.3/site-packages/decorator-2.2.0-
py2.3.egg', '/usr/lib/python2.3/site-packages/simplejson-1.7.1-py2.3-
linux-i686.egg',  '/usr/lib/python2.3/site-packages/setuptools-0.6c9-
py2.3.egg', '/usr/lib/python2.3/site-packages/Trac-0.11.2.1-
py2.3.egg', '/var/www/django/legend', '/usr/lib/python23.zip', '/usr/
lib/python2.3', '/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/
lib-tk', '/usr/lib/python2.3/lib-dynload', '/usr/lib/python2.3/site-
packages']

>
> ?
>
> And if you're really using mod_python already with Apache, also post
> your vhost file.
vhost file:
#Block conf
files###

Order allow,deny
Deny from all

#Django
mod_python###

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE legend.settings
PythonOption django.root /legend
PythonDebug On
PythonPath "['/var/www/django/legend'] + sys.path"


>
> To be honest though, if you're using Django for development you'd
> really be better off with the built-in runserver for the moment.

I am testing Django on my production server so that when development
is finished, I know I can actually use what I have done. There is no
point in doing the development if I am unable to use the work.


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Upload ZIP-File into Database

2009-02-08 Thread Karen Tracey
On Sun, Feb 8, 2009 at 7:24 AM, Robert  wrote:

>
> Dear Community,
>
> I have a ZIP-File which contains five .lst-Files. I want to fill with
> these five files a mysql-database. Is there a possibility to handle
> this via the admin interface? I tried the following but it doesn't
> work:
>

This sort of thing can certainly be done, the django-photologue application
(http://code.google.com/p/django-photologue/), for example, has a
GalleryUpload model that lets you upload a zip file of images and the zip
file is automatically expanded to its constituent images when you save a new
GalleryUpload object in the admin.  I have not looked at how exactly it is
implemented, but looking at its code might point you in the right direction.

If you want more specific help with the code you've got, giving people a
clue what "it doesn't work" looks like would probably help.  I like puzzles,
but I don't much like ones that are missing pieces, and leaving out the
details of what is going wrong: what you do, what you expect the outcome to
be, and what the outcome is instead, including any error messages and
tracebacks -- is leaving out a few too many pieces for me to have any
interest in looking at your puzzle.

Karen

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



Re: Iterating over a dictionary in templates

2009-02-08 Thread Carlos Pero

Oh excellent. New in 1.0, that makes sense. Thanks for the pointer.

On Feb 5, 10:00 am, Alex Gaynor  wrote:
> On Thu, Feb 5, 2009 at 10:21 AM, Carlos Pero  wrote:
>
> > Searching this group, I found a number of ways to iterate over a
> > dictionary in a template to get access to both the key and the value.
> > However, none of them covered the technique mentioned in this blog
> > post:
>
> >http://www.zedkep.com/blog/index.php?/archives/85-Iterating-over-a-di...
>
> > Maybe it's my PHP experience, but the syntax:
>
> > {% for key,value in dictionary.items %}{{ value }}{% endfor %}
>
> > is comforting because i have {{ key }} and {{ value }} available
> > separately and simply.
>
> > Though, this single dictionary structure I'm using is just a stopgap.
> > I think a list of dictionaries like the MUSICIANS example on this page
> > may be what I really need to pass to my template (to have multiple
> > values available):
>
> >http://www.djangobook.com/en/beta/chapter04/
>
> FYI this is in the official 
> docs:http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=old...
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Upload ZIP-File into Database

2009-02-08 Thread Robert

Dear Community,

I have a ZIP-File which contains five .lst-Files. I want to fill with
these five files a mysql-database. Is there a possibility to handle
this via the admin interface? I tried the following but it doesn't
work:

from django import forms
from django.contrib import admin
from cStringIO import StringIO
import zipfile
from dateiverwaltung.models import UploadZipFile

class UploadZipFileForm(forms.ModelForm):
class Meta:
model = UploadZipFile

zip_file = forms.Field(widget=forms.FileInput())
#zip_file = UploadZipFile.zip_file

def clean_zipfile(zip_file):
msg = 'File must be a valid ZIP-archive'
if zip_file.content_type != 'application/zip':
raise forms.ValidationError( msg )
else:
zipname = zip_file.name
zippfad = zip_file.chunks
zip = zipfile.ZipFile(fname)
assert False
try:
zip = zipfile.ZipFile(StringIO(zip_file.content))
except:
raise forms.ValidationError( "Not able to unpack the
archive" )
bad_file = zip.testzip()
zip.close()
del zip
if bad_file:
raise forms.ValidationError( msg )
return zip_file # Return the clean zip_file

zip_file.clean = clean_zipfile

class UploadZipFileAdmin(admin.ModelAdmin):
form = UploadZipFileForm
list_diplay = ('zip_file', 'uploadtime')

def save_model(self, request, obj, form, change):
pass

admin.site.register(UploadZipFile, UploadZipFileAdmin)


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Two forms one page

2009-02-08 Thread Masklinn


On 8 Feb 2009, at 10:18 , tsop wrote:
> The view:
> http://dpaste.com/118076/
>
> The template:
> http://dpaste.com/118077/
>
>
> King Regards,
> Titus

Since the forms seem pretty much disjoint, and are completely  
separated on the page itself (it's not like you're mixin two django  
Forms in a single HTML ), why don't you just send each form to  
its own view for validation?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Two forms one page

2009-02-08 Thread Horst Gutmann

You realize that you could simply do something like this to check if
'somefield' is a key in request.POST?

   if 'somefield' in request.POST:
  ...

;-)

On Sun, Feb 8, 2009 at 10:52 AM, tsop  wrote:
> Oh thanks!
> I didn't realize you could do that, it works now.
> I am using request.POST.__contains__(key), I think this is what you
> meant. =)
>
> Titus
>
> On Feb 8, 4:25 am, Horst Gutmann  wrote:
>> You could also assign the submit buttons a name (each its own name),
>> check request.POST for that name and then validate the respective form
>> :-)
>>
>> -- Horst
>>
>> On Sun, Feb 8, 2009 at 10:18 AM, tsop  wrote:
>> > Hello,
>> > I have a small problem here, I want to display two forms on the same
>> > page and I need both forms to validate/submit independently from one
>> > another. The problem I am having is that there is no way to tell which
>> > form is being submitted to, if they are both left empty and one submit
>> > is clicked both raise validation errors.
>>
>> > Since the view and template is quite a bit of code I've pasted them to
>> > a pastebin:
>>
>> > The view:
>> >http://dpaste.com/118076/
>>
>> > The template:
>> >http://dpaste.com/118077/
>>
>> > King Regards,
>> > Titus
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Two forms one page

2009-02-08 Thread tsop

Oh thanks!
I didn't realize you could do that, it works now.
I am using request.POST.__contains__(key), I think this is what you
meant. =)

Titus

On Feb 8, 4:25 am, Horst Gutmann  wrote:
> You could also assign the submit buttons a name (each its own name),
> check request.POST for that name and then validate the respective form
> :-)
>
> -- Horst
>
> On Sun, Feb 8, 2009 at 10:18 AM, tsop  wrote:
> > Hello,
> > I have a small problem here, I want to display two forms on the same
> > page and I need both forms to validate/submit independently from one
> > another. The problem I am having is that there is no way to tell which
> > form is being submitted to, if they are both left empty and one submit
> > is clicked both raise validation errors.
>
> > Since the view and template is quite a bit of code I've pasted them to
> > a pastebin:
>
> > The view:
> >http://dpaste.com/118076/
>
> > The template:
> >http://dpaste.com/118077/
>
> > King Regards,
> > Titus
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python and import path

2009-02-08 Thread Bradley Wright

On Feb 8, 4:39 am, Jeff  wrote:
> I installed django today and have not been able to get it to work with
> apache, or itself really.  I have the path in the sys.path and have
> set the settings module to point to it, but it cannot find it.  It
> works fine when I use 'python manage.py shell' or 'python manage.py
> validate' but when I export the environment settings, the 'django-
> admin.py validate' throws an error saying its not in the sys.path or
> isn't valid.

Could you please post:
- The directory your Django project is in;
- The directory Django itself is in; and
- The output from the following command:
python -c "import sys; print sys.path"

?

And if you're really using mod_python already with Apache, also post
your vhost file.

To be honest though, if you're using Django for development you'd
really be better off with the built-in runserver for the moment.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Two forms one page

2009-02-08 Thread tsop

Hello,
I have a small problem here, I want to display two forms on the same
page and I need both forms to validate/submit independently from one
another. The problem I am having is that there is no way to tell which
form is being submitted to, if they are both left empty and one submit
is clicked both raise validation errors.

Since the view and template is quite a bit of code I've pasted them to
a pastebin:

The view:
http://dpaste.com/118076/

The template:
http://dpaste.com/118077/


King Regards,
Titus

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---