Re: How to handle this race condition?

2009-11-09 Thread Tamas Szabo
Would something like UPDATE bid = new_bid WHERE id = id and bid < new_bid work for you? It is a more optimistic approach (it assumes that the case you describe is an exception rather than what usually happens) and I think it is simpler by not having to do any locking etc. Regards, Tamas

pre-save and check for existing value of image

2009-11-09 Thread Ramdas S
Hi, I have this app which has an ImageField, where the image needs to be cropped, resized, and a few effects (all from PIL) are applied on it, the model looks something like this class MidPanel(models.Model): . image = models.ImageField(upload_to="images"): def save(self):

Re: pre-save and check for existing value of image

2009-11-09 Thread ankit rai
You can check whether there is instance or not by self.instance .This will tell u that whether it is change (page)or a new object is added.And if it new object then only call ur custom functions.U can also use changeForm function On Tue, Nov 10, 2009 at 12:39 PM, Ramdas S

pre-save and check for existing value of image

2009-11-09 Thread Ramdas S
Hi, I have this app which has an ImageField, where the image needs to be cropped, resized, and a few effects (all from PIL) are applied on it, the model looks something like this class MidPanel(models.Model): . image = models.ImageField(upload_to="imgs") def save(self):

Re: domains vs sub-domains

2009-11-09 Thread Craig McClanahan
On Mon, Nov 9, 2009 at 9:38 PM, Chris wrote: > > I've recently been in discussion about which is better to have. > > http://media.example.com OR > http://example.com/media/ > > 1) The first method, I've been told, allows you to make more requests. > IE for example can

Re: annotation with filter issue (left join needed)

2009-11-09 Thread Михаил Лукин
Well, I didn't find solution yet. Except that filter condition must be placed in LEFT OUTER JOIN ... ON ( ), but i'm not sure if it's possible with Django ORM. I notices that Aggregate base class takes 'extra' argument in its constructor, but I'm not sure how to use it for such purpose. Any

help with EmailMultiAlternatives attach_file() or attach()

2009-11-09 Thread Margie Roginski
I asked a question earlier about trying to send an outlook message as an attachment, but didn't get a response. I'm so confused ... so I'm going to see if I can some up with a simpler question. I've have a file called 'foo.mht' that begins like this: Content-Type: message/rfc822

Re: domains vs sub-domains

2009-11-09 Thread Max Battcher
Chris wrote: > I've recently been in discussion about which is better to have. > > http://media.example.com OR > http://example.com/media/ > ... > Which method should I adopt? I personally like the second method, but > if it will effect performance/ loading times at all then I should go > with

Re: How to handle this race condition?

2009-11-09 Thread Continuation
Thanks Christophe and Kenneth! Let me make sure I understand this: If I write this vew function: @transaction.commit_on_success def update_high_bid(request): cursor = connection.cursor() cursor.execute("SELECT high_bid FROM auctionapp_auction WHERE id=%s FOR UPDATE", [auction.id])

Re: How to handle this race condition?

2009-11-09 Thread Christophe Pettus
On Nov 9, 2009, at 9:34 PM, Continuation wrote: > Also does django middleware acquire database lock on my behalf, or do > I need to explicitly perform the locking? In the example code, it's the SELECT ... FOR UPDATE that acquires the lock. Django doesn't currently have any explicit knowledge

Re: How to handle this race condition?

2009-11-09 Thread Christophe Pettus
On Nov 9, 2009, at 9:30 PM, Continuation wrote: > Can you tell me which middleware/decorator should I use to make sure > all those run within a single transaction? I'm pretty new to this. The transaction middleware will work:

domains vs sub-domains

2009-11-09 Thread Chris
I've recently been in discussion about which is better to have. http://media.example.com OR http://example.com/media/ 1) The first method, I've been told, allows you to make more requests. IE for example can only make like 4 requests at a given time on a given domain. but, if you use

Re: How to handle this race condition?

2009-11-09 Thread Kenneth Gonsalves
On Tuesday 10 Nov 2009 11:00:55 am Continuation wrote: > > """ Be sure this all runs inside a single transaction! Use the > > appropriate middleware or > > decorators... """ > > Thanks for your help. > > Can you tell me which middleware/decorator should I use to make sure

Re: How to handle this race condition?

2009-11-09 Thread Continuation
On Nov 10, 12:07 am, Christophe Pettus wrote: > Beware of deadlocks!  Keep the number of tables on   > which you acquire locks to a minimum, and acquire them in the same   > order in all places in your code. Also does django middleware acquire database lock on my behalf, or

Re: How to handle this race condition?

2009-11-09 Thread Continuation
On Nov 10, 12:07 am, Christophe Pettus wrote: >         """ Be sure this all runs inside a single transaction!  Use the   > appropriate middleware or >             decorators... """ Thanks for your help. Can you tell me which middleware/decorator should I use to make sure

Re: How to handle this race condition?

2009-11-09 Thread Christophe Pettus
On Nov 9, 2009, at 8:36 PM, Continuation wrote: > When a new_bid comes in, I: > 1) retrieve the current_high_bid field of the Auction object > 2) compare it with the new_bid > 3) if the new bid is higher than current_high_bid, I update > current_high_bid to the value of the new_bid. > > but

How to handle this race condition?

2009-11-09 Thread Continuation
I'm working on an auction app. In an Auction object I store the current_high_bid for that auction. When a new_bid comes in, I: 1) retrieve the current_high_bid field of the Auction object 2) compare it with the new_bid 3) if the new bid is higher than current_high_bid, I update current_high_bid

TemplateSyntaxError

2009-11-09 Thread Zeynel
Hello, These are my tables: BEGIN; CREATE TABLE "wkw_school" ( "id" integer NOT NULL PRIMARY KEY, "school" varchar(200) NOT NULL ) ; CREATE TABLE "wkw_lawyer" ( "id" integer NOT NULL PRIMARY KEY, "first" varchar(20) NOT NULL, "initial" varchar(2) NOT NULL, "last"

MySQL and 'NoneType object is unsubscriptable' error

2009-11-09 Thread Julien Phalip
Hi, I've tried to install MySQL for an existing project, and I'm getting a strange error (see traceback below). Apparently "self.converter" is None, but I can't see why. I can access the database just fine using the 'mysql' command in the terminal or using PhpMyAdmin. Do you know how this

Re: Another Django vs. Rails comparison

2009-11-09 Thread Paul Eastlund
This is a helpful list of pros/cons. Thanks. Your "development philosophy" point especially matches up well with my own experience. A friend and I just wrote a website for a new small business ( http://www.final-draft-editing.com/) and chose Django -- after an initial trial of Ruby on Rails --

Re: User class, change name of fields(like username with login name)

2009-11-09 Thread Preston Holmes
On Nov 9, 7:49 am, NMarcu wrote: > Hello all, > >    I have a list of all users. My head table is made with the fields > from User class. So look like this: > > username           first name             last name > superuser status > > I want to make this head table

Re: Help about models

2009-11-09 Thread Zeynel
Hello Greg and Jirka, Thanks for the help. I was rereading the tutorial to understand the ForeignKey. It says that ForeignKey "tells Django each Choice is related to a single Poll." In my case, each lawyer is associated with 1 law school; and each law school is associated with 1 or more

Re: Templates,layout, css, ie and Pyjamas

2009-11-09 Thread Ishwor Gurung
Grant, Hi 2009/11/10 grant neale : > > Hi Ishwor, > > I'm in France I'm afraid. > Is there any solution out there for getting the basics up and running - Download a copy of Django and give it a go. - Extract it to a folder - Run 'python setup.py install'; - Go to django

Re: Django internationalization problem: Error: errors happened while running xgettext on __init__.py /bin/sh: xgettext: command not found

2009-11-09 Thread rebus_
2009/11/9 NMarcu : > > Hello all, > >   When I run django-admin.py makemessages -l ro I got this: > Error: errors happened while running xgettext on __init__.py > /bin/sh: xgettext: command not found > > You know why, I need to install somethng else? > > > are you sure

how to send an rfc822 email attachment

2009-11-09 Thread Margie Roginski
I am trying to write some add code to my app that accepts an email from the user that contains attachments, adds those attachments to the database and then sends an email containing those attachments. I am trying to get my code to work for the case were the attachment is an outlook mail (ie, an

Another Django vs. Rails comparison

2009-11-09 Thread Jason
This is my first post to this group, but I've benefited from reading other's posts and I'm looking forward to getting more involved. I just picked Django/Python as the framework for a new company I just started: FeedMagnet (http://feedmagnet.com). We want to get more involved in the community -

Re: Prevent brute-force password attacks?

2009-11-09 Thread f4nt
Yes, teaching users to not choose stupid username/password combinations. That's the only correct/true fix. Are you worried about the traffic that it consumes? If so, you continue to play in dicey territory, since you're trying to deduce harmful bots from potentially stupid users that just can't

Re: Prevent brute-force password attacks?

2009-11-09 Thread Jorge Bastida
Check http://code.google.com/p/django-axes/ Bye ! 2009/11/9 Adam Seering > > Hi, >Does there exist any code for Django to help defeat brute-force > login > attempts? Something like blocking IP addresses from logging in if they > try and fail too many times, etc. > >

Prevent brute-force password attacks?

2009-11-09 Thread Adam Seering
Hi, Does there exist any code for Django to help defeat brute-force login attempts? Something like blocking IP addresses from logging in if they try and fail too many times, etc. Adam --~--~-~--~~~---~--~~ You received this message because you are

Re: DRY: max length not taken from Model.field when using ModelForm

2009-11-09 Thread fest
Tomasz, it was obvious for me too, however, I had defined a form, which had some fields overridden, but some not- I was hoping that options for fields that were not overridden were preserved, but due to specific way admin interface handles forms, required class wasn't added to my custom form

Django internationalization problem: Error: errors happened while running xgettext on __init__.py /bin/sh: xgettext: command not found

2009-11-09 Thread NMarcu
Hello all, When I run django-admin.py makemessages -l ro I got this: Error: errors happened while running xgettext on __init__.py /bin/sh: xgettext: command not found You know why, I need to install somethng else? --~--~-~--~~~---~--~~ You received this

Re: how to create a faceted browser with Django

2009-11-09 Thread Daniel Roseman
On Nov 9, 4:24 am, SeanB wrote: > Many web sites offer faceted browsing such that a series of categories > can be selected to narrow a large set of records down to a few (or > one). Such interfaces often show how many records match the various > category values, which

Re: how to create a faceted browser with Django

2009-11-09 Thread SeanB
as a follow-up: list_filter attributes in the admin interface provide part of what i mean, but only part. Given a set of restrictions, the admin interface: * shows all possible choices, rather than the only remaining choices that are possible * doesn't show counts Sean On Nov 8, 8:24 pm, SeanB

How can I change the verbose_name of a field and save this in model, or db, from a view?

2009-11-09 Thread NMarcu
Hello, I want to change the verbose_name to is_superuser, on User class. The current one is superuser status, and I want to make this field editable, and I need to change this verbose_name from view, how can I do this? --~--~-~--~~~---~--~~ You received this

User class, change name of fields(like username with login name)

2009-11-09 Thread NMarcu
Hello all, I have a list of all users. My head table is made with the fields from User class. So look like this: username first name last name superuser status I want to make this head table editable. How can I change the caption of the field, not the name of it. By

Re: Templates,layout, css, ie and Pyjamas

2009-11-09 Thread grant neale
Hi Ishwor, I'm in France I'm afraid. Is there any solution out there for getting the basics up and running and then going into the "beauty contest" later? Or are you just saying that it's hard, just eat your lunch? If you ever come to France, I can send you some links on where to stay. :)

Re: Stuck with csrf_token in the tutorial

2009-11-09 Thread wietse
On Nov 9, 3:38 pm, Karen Tracey wrote: > On Mon, Nov 9, 2009 at 9:35 AM, wietse wrote: > > Running django 1.1.1 > > > I'm going through the tutorial and have run into trouble implementing > > a form, I get: > >    TemplateSyntaxError at /polls/1/ > >    

Re: Databrowse: Loading a large number of records

2009-11-09 Thread sstein...@gmail.com
On Nov 9, 2009, at 7:49 AM, Ismail Dhorat wrote: > I also see there has been a ticket logged for this issue about 2 > years ago. > > http://code.djangoproject.com/ticket/4481 > > Has this been implemented? If not would would a simple paginate tag in > the template suffice? Have you tried

Re: Stuck with csrf_token in the tutorial

2009-11-09 Thread Karen Tracey
On Mon, Nov 9, 2009 at 9:35 AM, wietse wrote: > > Hello, > > Running django 1.1.1 > > I'm going through the tutorial and have run into trouble implementing > a form, I get: >TemplateSyntaxError at /polls/1/ >Invalid block tag: 'csrf_token' > > csrf_token didn't exist

Stuck with csrf_token in the tutorial

2009-11-09 Thread wietse
Hello, Running django 1.1.1 I'm going through the tutorial and have run into trouble implementing a form, I get: TemplateSyntaxError at /polls/1/ Invalid block tag: 'csrf_token' I've searched around but find it hard to grok what I need to do. In settings.py I have:

Re: django generic views w multiple models

2009-11-09 Thread Ross
Ok I think I've honed my problem down a bit further and more concisely: So I'm trying to create an Info object that is attached to a League object, but I can't do this through the urlconf the way I have it now because create_object() does not take an object id as an argument. Somehow, I need to

Re: Templates,layout, css, ie and Pyjamas

2009-11-09 Thread Ishwor Gurung
Hi, 2009/11/10 grant neale : > > Hi, > > I'm a hobbyist and do not have a lot of time on my hands to do front > end (templates, css) stuff. Hire a professional to do you it for you. > I was looking around and saw that pyjamas takes care of the layout of > the user interface.

Re: matplotlib usage problem

2009-11-09 Thread Karen Tracey
On Mon, Nov 9, 2009 at 8:36 AM, Oguz Yarimtepe wrote: > > Hi, > > I was trying to use the matplotlib at my Django view. The version i was > trying is 0.98. What i did is to import the library and then plot a graph. > The problem is when i tried the "from pylab import *", i

Re: matplotlib usage problem

2009-11-09 Thread Torsten Bronger
Hallöchen! Oguz Yarimtepe writes: > I was trying to use the matplotlib at my Django view. The version > i was trying is 0.98. What i did is to import the library and then > plot a graph. The problem is when i tried the "from pylab import > *", i got "RuntimeError: could not create GdkCursor

matplotlib usage problem

2009-11-09 Thread Oguz Yarimtepe
Hi, I was trying to use the matplotlib at my Django view. The version i was trying is 0.98. What i did is to import the library and then plot a graph. The problem is when i tried the "from pylab import *", i got "RuntimeError: could not create GdkCursor object". This is most probably because

Templates,layout, css, ie and Pyjamas

2009-11-09 Thread grant neale
Hi, I'm a hobbyist and do not have a lot of time on my hands to do front end (templates, css) stuff. I was looking around and saw that pyjamas takes care of the layout of the user interface. Is this a reasonable solution to use instead of Django's templates? Are there any other solutions

[uploadify] passing user info to the signal handler

2009-11-09 Thread Mike Thon
The django-uploadify app allows bulk file uploads and for each uploaded file, it fires a signal and passes the uploaded file data to the receiver. The author's example marks all the uploaded files with a boolean (new_upload=True) and then returns a list of files where new_upload=True to the

Databrowse: Loading a large number of records

2009-11-09 Thread Ismail Dhorat
Hi Guys, I am currently testing the contrib app databrowse in Django ver 1.1.1, the current setup for testing purposes is: OS: Mac OsX 10.6 DB: Sqlite3 Django: 1.1.1 Python: 2.5 Here is what i have done, i have a model and i am trying to see what the capabilities and limits of this app (since

Re: Display a view of a single record?

2009-11-09 Thread Ludwik Trammer
I have a really hard time understanding what do you need, and I suspect I'm not the only one. You are talking about the admin interface, right? It displays a list containing all records, and when you click on a record you go to a page that shows all fields for this record (and lets you change

Re: Help about models

2009-11-09 Thread Jirka Vejrazka
> I commented out the ForeignKey because it caused an error. Just a small coding note - it was causing an error because you did not specify the model name exactly (compare the character case) Jirka --~--~-~--~~~---~--~~ You received this message because you

Re: Template Syntax Error: url config module not found

2009-11-09 Thread m3mitsuppe
Ok, so I narrowed this down a bit: the problem was with get_absolute_url. I still do not understand why it would complain about the urls.py not being found. I'd still be happy about any hints, but in the meantime I changed my template code to a not-so-DRY but working version with explicit urls.

memcached isspace(3) on server start with any cache refference

2009-11-09 Thread timjdavey
Hey I'm getting: mcm_validate_key_func():3443: memcache(4) protocol error: isspace(3) returned true for character in key error when I start a server (right after the "Validating models" step). The weird and annoying part is - is that I've not yet implemented cache anywhere yet. Only in

Re: Collapsible fields

2009-11-09 Thread Lars Stavholm
Daniel Roseman wrote: > On Nov 9, 8:47 am, Lars Stavholm wrote: >> Hi All, >> >> I'm looking to implement collapsible fields in a django powered >> page, so far with no luck. >> >> Any hints on the best way of doing it? >> >> In the mean time, I checked out how it's done in

Re: Collapsible fields

2009-11-09 Thread Daniel Roseman
On Nov 9, 8:47 am, Lars Stavholm wrote: > Hi All, > > I'm looking to implement collapsible fields in a django powered > page, so far with no luck. > > Any hints on the best way of doing it? > > In the mean time, I checked out how it's done in the admin interface, > and came up

Re: Helsinki area djangonauts: Let's meet up

2009-11-09 Thread akaihola
Count me in. Also sent the message to three djangonauts I know who are not on djangopeople. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Django web flow

2009-11-09 Thread bruno desthuilliers
On 8 nov, 17:49, Lana wrote: > Hi! > > Does Django have some sort of web flow similar to the Spring web flow > in Java? Err... Do we have to read Spring's doc to find out what this means ? --~--~-~--~~~---~--~~ You received this message

Running doctests of app custom filters

2009-11-09 Thread Nicolas Perriault
Hi, first timer message here :) I'm discovering both Django and Python and loving them so far. I'm pretty excited by the abilities offered by doctests. I've written some custom template filters and would like their doctests to be executed when I run ./manage.py test myapp. I didn't find a way

Collapsible fields

2009-11-09 Thread Lars Stavholm
Hi All, I'm looking to implement collapsible fields in a django powered page, so far with no luck. Any hints on the best way of doing it? In the mean time, I checked out how it's done in the admin interface, and came up with a simple test page as follows: