Re: environment variables in virtualenv's postactivate using mod_wsgi

2013-05-22 Thread Graham Dumpleton
On Thursday, 23 May 2013 07:57:02 UTC+10, ke1g wrote:
>
> Since my Apache virtualhost file contains
>>
>> WSGIDaemonProcess mysite.local 
>> python-path=/my/python/path:/path/to/my/project/venv/lib/python2.7/site-packages
>>
>
> If memory serves, this does not cause the .pth files in site-packages to 
> be applied.  Could be OK.  Could be a problem.
>

It has processed .pth files and ensured that path ordering is done as 
necessary since mod_wsgi 2.0.
 

> WSGIProcessGroup mysite.local
>> WSGIScriptAlias / /path/to/my/project/wsgi.py
>>
>
> This wouldn't be the wsgi.py created by manage.py startproject, would it?  
> It's necessary these days for manag.py runserver, but I've yet to find it 
> adequate to use with mod_wsgi.  (I must confess that I haven't played with 
> it for at least 6 months.)  It's not too hard to write your own, taking all 
> the path manipulations, that runserver doesn't need but mod_wsgi does, into 
> account.
>

Except for setdefault() being used to set environment variables causing 
issues in some cases:

http://blog.dscpl.com.au/2012/10/requests-running-in-wrong-django.html

the generated wsgi.py file should be fine, you can do all the path setup 
from mod_wsgi.

A reasonable configuration if using mod_wsgi 3.4 would be:

WSGIDaemonProcess example.com 
python-home=/path/to/your/venv python-path=/path/to/mysite.com
WSGIProcessGroup example.com
WSGIApplicationGroup %{GLOBAL}
WSGIRestrictEmbedded On

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py

This is mostly covered in:

https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/

with the exception that using python-home in this example.

The WSGIRestrictEmbedded directive turns off Python in the Apache worker 
processes since you are using a daemon process group. Saves on memory and 
CPU startup cost of worker processes.

The WSGIApplicationGroup with value %{GLOBAL} for daemon process forces use 
of main interpreter, avoiding creation of a second sub interpreter context 
and avoids issues with some third party C extension modules which do not 
work properly in sub interpreters.

Graham

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




Re: Multi Client Django System

2013-05-22 Thread Richard E. Cooke
Frank!

You appear to have figured out what I spent most of today trying to figure 
out:  How to get access to the current logged in user from INSIDE a custom 
data manager!

Can you clarify something in your code?

In your custom manager you define "by_user", which takes "user" as an 
input.  But in your class you just name your custom data manager in place 
of the default "object" manager.

How do you ( a ) get the system to call your "by user" query?  And ( b ) 
how do you get the system to send in the current "user"?

I was thinking there might be a link through the site.model reference 
Managers get.  Or maybe a way to pull it from session, but I keep get stuck 
on the fact this isn't a view, so it has no obvious access to a "request" 
object

Thanks in advance!



On Monday, February 25, 2013 4:18:50 AM UTC-5, Frank Bieniek wrote:
>
> We achived the second level auth, by tying an extended group to a company, 
> all company members are part of this group, so we can leverage the 
> normal auth mechanismen. 
>
> Hope this gives you an idea. 
>
> Thanks 
> Frank 
>
> class CompanyManager(models.Manager): 
>  filter_by_user_limit_field = None 
>
>  def by_user(self, user): 
>  """ 
>  Extension for filtering organization objects (also related 
> objects) by 
>  the groups of a user. 
>  Avoiding that a user can touch other organization objects. 
> Superusers and 
>  Partner Administrators are able to see all organizations. 
>  """ 
>  # if the user is not logged in - no data 
>  if not user.is_authenticated(): 
>  return self.none() 
>  # TODO: optimization: would be nice to find a way to make 
> by_user chainable like .filter(), ... 
>  return self.limit_queryset_by_user( 
>  self.get_query_set(), 
>  user, 
>  self.model.filter_by_user_limit_field 
>  ) 
>
>  @staticmethod 
>  def limit_queryset_by_user(qs, user, field_key): 
>  if user.is_superuser.count()>0: 
>  return qs 
>  kwargs = {} 
>  if field_key and user.groups.count() > 0: 
>  kwargs[field_key] = [u['id'] for u in 
> user.groups.values('id')] 
>  return qs.filter(**kwargs) 
>
> And in the model 
>
> class Company(ExtendedModel): 
>  name = models.CharField(max_length=64, unique=True) 
>  slug = models.SlugField(unique=True) 
>  is_active = models.BooleanField(null=False, blank=False, 
> default=True) 
>
>  filter_by_user_limit_field = "organizationgroup__in" 
>  objects = CompanyManager() 
>
> class CompanyGroup(Group): 
>  """ 
>  User group of the Organization 
>  """ 
>  organization = models.OneToOneField(Organization) 
>
>
> Am 23.02.2013 17:00, schrieb Gabriel - Iulian Dumbrava: 
> > How I would do it would be to have a special column (foreign key) in 
> each table (model) called Company (company_id) and change all default 
> managers to filter on company_id = logged_in_user.company_id. 
> > 
> > In this way you are sure tha users only see what belongs to their 
> company. 
> > 
> > You would have to pass the company_id to models, probably with a 
> middleware which gets it from the logged in user and saves it somewhere. 
> > 
> > And you also have to save the default value of company_id to each newly 
> created entry in every table, probably from the same source as above. 
> > 
>
>

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




Re: Show HTML in Labels for Model Choice Fields

2013-05-22 Thread Guillermo Siliceo
Hey Adi your answer saved me lots of work, but i want to elaborate on it, i 
had this use case but i didnt have to subclass the field all i did was 
defined a new label_from_instance

def Option_with_specie(self):
return mark_safe(" %s 
"%(self.species.name, self.pk, self.name)) 

And then on the forms init:

class PetForm(forms.ModelForm):

def __init__(self, *args, **kwargs):
super(PetForm, self).__init__(*args, **kwargs)
if 'instance' in kwargs:
self.fields['breed'].label_from_instance = Option_with_specie

So now i customized the select field outputted by the foreing key, thanks 
to you Adi for finding just the right method to override.

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




Re: IdeaScale-alike DJango applications

2013-05-22 Thread Russell Keith-Magee
On Wed, May 22, 2013 at 6:53 PM, Daniele Procida  wrote:

> Are there any Django applications that do the same thing as <
> http://ideascale.com>?
>
> IdeaScale basically seems to be a way for users to submit proposals, and
> have them voted up and down by other users; like polls, but in a web
> 2.1beta kind of way.
>
> It's something I've been asked about.
>
> Any suggestions?
>
> Hi Daniele,

Are you looking for an app that implements ideascale-like ideas for your
own purposes, or are you suggesting an ideascale-like framework to drive
Django development?

If it's the former, then you're really just looking at tying something
contrib.comments (or equivalent) and django-voting to a model that
represents an "idea".

If you're talking about the latter, then it's possible to use CC counts or
comment counts as an approximation of interest in a topic; but it might be
interesting to see a literal "I want this" vote count associated with
tickets.

Yours,
Russ Magee %-)

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




Re: site critique

2013-05-22 Thread frocco
Thanks, I need to work on getting the font size corrected.

On Wednesday, May 22, 2013 6:01:51 PM UTC-4, Nigel Legg wrote:
>
> Ah yes. main site home page has a variety of font sizes which looks a 
> bit odd. 
>
> Regards,
> Nigel Legg
> 07722 652866
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 22 May 2013 22:59, Nikolas Stevenson-Molnar 
> 
> > wrote:
>
>>  The link is actually to an admin page.
>>
>> _Nik
>>
>>
>> On 5/22/2013 2:53 PM, Nigel Legg wrote:
>>  
>> Site is asking for a username and password, so I can't look at it. 
>>  
>>  Regards,
>> Nigel Legg
>> 07722 652866
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/nigellegg
>>
>>   
>>
>> On 22 May 2013 14:24, frocco > wrote:
>>
>>> Hi Every one, 
>>>
>>>  I have my PHP site up and running that I converted to django.
>>> Would you have a look at this production site and let me know your 
>>> opinions?
>>>
>>>  Current users are very fussy and resist change.
>>>
>>>  http://ntwarehouse.net
>>>
>>>  
>>>  One problem I have is SEO is not working correctly.
>>> If I search on TIRES, my site does not show.
>>>
>>>  I am new to SEO, and have having a hard time trying to figure out what 
>>> needs to be done.
>>>
>>>  Thanks
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>  
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

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




Re: site critique

2013-05-22 Thread Nigel Legg
Ah yes. main site home page has a variety of font sizes which looks a
bit odd.

Regards,
Nigel Legg
07722 652866
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 22 May 2013 22:59, Nikolas Stevenson-Molnar wrote:

>  The link is actually to an admin page.
>
> _Nik
>
>
> On 5/22/2013 2:53 PM, Nigel Legg wrote:
>
> Site is asking for a username and password, so I can't look at it.
>
>  Regards,
> Nigel Legg
> 07722 652866
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 22 May 2013 14:24, frocco  wrote:
>
>> Hi Every one,
>>
>>  I have my PHP site up and running that I converted to django.
>> Would you have a look at this production site and let me know your
>> opinions?
>>
>>  Current users are very fussy and resist change.
>>
>>  http://ntwarehouse.net
>>
>>
>>  One problem I have is SEO is not working correctly.
>> If I search on TIRES, my site does not show.
>>
>>  I am new to SEO, and have having a hard time trying to figure out what
>> needs to be done.
>>
>>  Thanks
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: site critique

2013-05-22 Thread Nikolas Stevenson-Molnar
The link is actually to an admin page.

_Nik

On 5/22/2013 2:53 PM, Nigel Legg wrote:
> Site is asking for a username and password, so I can't look at it.
>
> Regards,
> Nigel Legg
> 07722 652866
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 22 May 2013 14:24, frocco  > wrote:
>
> Hi Every one,
>
> I have my PHP site up and running that I converted to django.
> Would you have a look at this production site and let me know your
> opinions?
>
> Current users are very fussy and resist change.
>
> http://ntwarehouse.net
> 
>
>
> One problem I have is SEO is not working correctly.
> If I search on TIRES, my site does not show.
>
> I am new to SEO, and have having a hard time trying to figure out
> what needs to be done.
>
> Thanks
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users+unsubscr...@googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




Re: environment variables in virtualenv's postactivate using mod_wsgi

2013-05-22 Thread Bill Freeman
On Wed, May 22, 2013 at 12:41 PM, Charles Mulder wrote:

> Hi,
>
> Hope you're well.
>
> I've added a couple of environment variables to my virtualenv postactivate
> file, for example:
>
> export DATABASE_USER="root"
> export DATABASE_PASSWORD="12345678"
>

N.B. that environment variables are not as secure as you might hope (though
certainly better than passwords on the command line).

>
> I then assign those variables in my settings.py using
> os.environ['DATABASE_USER'], for example
>
> DATABASE_USER = os.environ['DATABASE_USER']
>
> Since my Apache virtualhost file contains
>
> WSGIDaemonProcess mysite.local
> python-path=/my/python/path:/path/to/my/project/venv/lib/python2.7/site-packages
>

If memory serves, this does not cause the .pth files in site-packages to be
applied.  Could be OK.  Could be a problem.
If you have only one wsgi script on that Apache, you might consider the
WSGIPythonHome directive (the directive must be global, rather than in a
vhost, thus there can be only one).
Or, if you have a new enough mod_wsgi, the WSGIDaemonProcess directive also
takes a "python-home" argument  (I do have three or four ve's running on
one Apache this way).  There are some restrictions as to other
configuration stuff, but the defaults work for me.
Otherwise you need to play with sys.path in your wsgi script, or at least
invoke site.addsitedir() correctly, see:
http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

WSGIProcessGroup mysite.local
> WSGIScriptAlias / /path/to/my/project/wsgi.py
>

This wouldn't be the wsgi.py created by manage.py startproject, would it?
It's necessary these days for manag.py runserver, but I've yet to find it
adequate to use with mod_wsgi.  (I must confess that I haven't played with
it for at least 6 months.)  It's not too hard to write your own, taking all
the path manipulations, that runserver doesn't need but mod_wsgi does, into
account.

>
> As I understand it, this tells mod_wsgi to run in daemon mode and which
> virtualenv to use.
> Since it knows which virtualenv to use, I would image it would run
> postactivate, thereby enabling my environment variables, but this however
> is not the case.
>

mod_wsgi does not "activate" the virtualenv.  You will have to find
somewhere else to add environment variables.  Maybe in some Apache config
file, but more likely in your wsgi script.

The only truly useful thing that activate normally does is to put the
directory containing the venv's python early on the shell path.  If you run:

  /absolute/path/to/ve/bin/python manage.py runserver

It will work just fine (for folks who don't depend on other actions like
setting environment variables in postactivate).

You can use *nix's cmp command to confirm that the python is an unmodified
of the(a) system python.  The whole trick to virtualenv is that, if the
PYTHONHOME environment variable isn't set. python uses the location of the
executable file to figure out where the correct lib/pythonX.X directory is.


> Am I doing something wrong? Any suggestions or recommendations are
> welcome.
>
> Kind regards,
>
>
>

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




Re: site critique

2013-05-22 Thread Nigel Legg
Site is asking for a username and password, so I can't look at it.

Regards,
Nigel Legg
07722 652866
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 22 May 2013 14:24, frocco  wrote:

> Hi Every one,
>
> I have my PHP site up and running that I converted to django.
> Would you have a look at this production site and let me know your
> opinions?
>
> Current users are very fussy and resist change.
>
> http://ntwarehouse.net
>
>
> One problem I have is SEO is not working correctly.
> If I search on TIRES, my site does not show.
>
> I am new to SEO, and have having a hard time trying to figure out what
> needs to be done.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




custmoizing admin using template files

2013-05-22 Thread Christopher Spears
Hi!

I am working through the Django tutorial, and I have reached the part where 
I want to customize my admin.  Basically,  I want 'Chris Spears App' to 
appear at the top of the page instead of 'Django administration'.

I copied the base_site.html file from its home to 
C:\Users\Chris\Documents\django_dev\mysite\templates\admin.

I then modified the file like so:

{% extends "admin/base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %}

{% block branding %}
{% trans 'Chris Spears App' %}
{% endblock %}

{% block nav-global %}{% endblock %}

I then modified the settings.py file:

import os

# Django settings for mysite project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

BASE_DIR = 'C:\Users\Chris\Documents\django_dev\mysite'
#BASE_DIR = os.path.dirname(os.path.dirname(__file__))

TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]

For some reason, I can't get the change to work.  I'm pretty sure that I am 
referencing the wrong file, but I can't figure out how to print the value 
of TEMPLATE_DIRS.  Any advice?

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




Re: New user - template errors.

2013-05-22 Thread Nigel Legg
Cool, thanks.  And sorry - I should have gone there first.

Regards,
Nigel Legg
07722 652866
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 22 May 2013 17:01, Michael  wrote:

> Hi Nigel, take a look at these, they might provide some answers:
>
>
> http://stackoverflow.com/questions/14892462/django-error-upolls-is-not-a-registered-namespace
>
>
> http://stackoverflow.com/questions/16049972/django-tutorial-04-noreversematch-at-polls-1-upolls-is-not-a-registered-na
>
>
> On Wednesday, 22 May 2013 11:10:02 UTC+1, Nigel Legg wrote:
>>
>> Morning/Afternoon - I am new to django, and I have been working through
>> the tutorial.  I have reached Tutorial 4, https://docs.djangoproject.**
>> com/en/1.5/intro/tutorial04/,
>> which is about getting the voting on the polls app to work, but when I set
>> detail.html I get an error, "
>> NoReverseMatch at /polls/2/
>>
>> u'polls' is not a registered namespace
>>
>> What would cause that?
>>
>> Many thanks.
>>
>> Regards,
>> Nigel Legg
>> 07722 652866
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/**nigellegg
>>
>>   --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Understanding Django transactions

2013-05-22 Thread Michael
Hi Aymeric,

That's awesome, really appreciate you clarifying all of that! Look forward 
to watching the video of your talk, the slides look great.

Cheers!


On Tuesday, 21 May 2013 17:43:00 UTC+1, Aymeric Augustin wrote:
>
> Hi Michael,
>  
>>
>> *Django 1.5:*
>>
>
>>- The database-level auto-commit is turned OFF.
>>
>> Yes. 
>
>>
>>- SQL standards dictate that every query opens a transaction if one 
>>does not already exist. This happens regardless of the database's 
>>auto-commit setting.
>>
>> Yes, this is required by PEP 249 and taken care of by the database 
> adapter. 
>
>>
>>- After each Django ORM operation (read or write), Django commits 
>>this open transaction. This emulates the database-level auto-commit.
>>
>> No, transactions are only committed after write operations, so it isn't 
> exactly like database-level autocommit. 
>
>>
>>- Transaction decorators cannot be nested. When one is opened, any 
>>previous transaction will be committed.
>>
>>  Not necessarily. It's complicated. It depends on the previous state 
> (auto / managed), the current state (auto / managed) and the dirty flag.
>
> I never understood the logic. Your best chance is to read the source if 
> you really need to know how it works.
>
>>
>>- When executing raw SQL (with a database cursor), Django marks the 
>>current transaction as dirty but does not issue a commit. If data changes 
>>were made then they need manually committing. *Why do the 
>> **docs*
>>* say that you only need to commit the change if data was changed? If 
>>the transaction is marked as dirty regardless of a read or a write, would 
>>it not always need committing or rolling back to ensure the transaction 
>> is 
>>properly closed by the end of the connection?*
>>
>> In Django 1.2 and earlier, the connection wasn't marked dirty on raw SQL 
> operations. If you didn't commit and you didn't perform any other writes 
> until the end of the query, Django would issue a rollback.
>
> In Django 1.3-1.5, I'm not sure what happens exactly. I believe the 
> transaction management will always issue a commit or a rollback before the 
> connection is aborted and closed by the request_finished signal, but I 
> could be wrong.
>
> Honestly, when I rewrote transaction management, no one understood how it 
> interacted with the dirty flag. So I can't answer this question and I don't 
> think anyone else can. Once again, read the source if you need to know how 
> it works in a specific case.
>
>>
>>- Setting TRANSACTIONS_MANAGED to True stops Django from sending any 
>>commits after ORM operations. The database-level auto-commit is still 
>>disabled.* With this setting, using any Django ORM read or write 
>>operation (all wrap**ped in `transaction.commit_on_success`) fails 
>>with TransactionManagementError('This code isn't under transaction 
>>management'). Is this expected?*
>>
>> I have no idea.
>
>>
>>
>> *Django 1.6:*
>>
>>- The database-level auto-commit is turned ON. 
>>- Every database operation via the ORM will be committed using the 
>>database's auto-commit, including any custom SQL executed with the 
>> database 
>>cursor. 
>>- The `atomic` decorator / context manager either starts a new 
>>transaction, or creates a new savepoint if it's nested within an existing 
>>transaction. They are committed as long as no exception is raised. 
>>- If ATOMIC_REQUESTS is specified in the database config, all views 
>>are wrapped in `atomic`, unless it's wrapped in `non_atomic_requests`.
>>
>> Yes, these four sentences are correct. 
>
>>
>>- If you set AUTOCOMMIT to False in a database configuration, this 
>>will disable the database-level auto-commit. All DB reads and writes will 
>>need manually wrapping in transactions. *The 
>> **docs*
>>* say that with this disabled, Django won't perform any commits. Does 
>>this mean that the `atomic` decorator won't work properly and you have to 
>>use the underlying database library to handle transactions? In 1.6 it 
>> would 
>>appear that Django never performs a commit outside of `atomic`, so I'm 
>>confused by this comment!* 
>>
>> First, it's extremely unlikely that you will ever need to set AUTOCOMMIT 
> to False. This is only useful if you want to implement your own transaction 
> management, and I don't know anyone who's done that, nor a use case for 
> doing that. I'd be surprised if this discussion was relevant to a single 
> person on this mailing list (but I've been surprised before!). Also, your 
> link goes to the 1.5 docs, not the dev docs. This may have confused you.
>
> Anyway, in this scenario, `atomic` will work as expected. When autocommit 
> is off, you're always in a transaction, and as a conseq

Unable to get notifications - Django Push

2013-05-22 Thread surya
I am using Django-push project for my app. What I am doing is, read my 
blog, find whether new updates available. If present, store in the db.

This is not happening! The source code is here : 
https://gist.github.com/5628801  

So, if would be great if someone could let me know where I am doing mistake 
and how it should be corrected.

Thanks

PS: the working environment is Python 2.7, Django 1.4.5 (Django-push: 
https://github.com/brutasse/django-push)

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




environment variables in virtualenv's postactivate using mod_wsgi

2013-05-22 Thread Charles Mulder
Hi, 

Hope you're well. 

I've added a couple of environment variables to my virtualenv postactivate 
file, for example:

export DATABASE_USER="root"
export DATABASE_PASSWORD="12345678"

I then assign those variables in my settings.py using 
os.environ['DATABASE_USER'], for example

DATABASE_USER = os.environ['DATABASE_USER']

Since my Apache virtualhost file contains

WSGIDaemonProcess mysite.local 
python-path=/my/python/path:/path/to/my/project/venv/lib/python2.7/site-packages
WSGIProcessGroup mysite.local
WSGIScriptAlias / /path/to/my/project/wsgi.py

As I understand it, this tells mod_wsgi to run in daemon mode and which 
virtualenv to use.
Since it knows which virtualenv to use, I would image it would run 
postactivate, thereby enabling my environment variables, but this however 
is not the case. 

Am I doing something wrong? Any suggestions or recommendations are welcome. 

Kind regards,
C

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




DjangoCon US 2013 CFP is open

2013-05-22 Thread Christophe Pettus
Hi, all,

The Call for Proposals for DjangoCon US 2013 is now open!  We encourage 
everyone, regardless of speaking experience, to submit a proposal.  We're 
particularly interested this year in hands-on experiences and case-studies:

http://www.djangocon.us/cfp/

Thanks!
--
-- Christophe Pettus
   x...@thebuild.com

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




Re: New user - template errors.

2013-05-22 Thread Michael
Hi Nigel, take a look at these, they might provide some answers:

http://stackoverflow.com/questions/14892462/django-error-upolls-is-not-a-registered-namespace

http://stackoverflow.com/questions/16049972/django-tutorial-04-noreversematch-at-polls-1-upolls-is-not-a-registered-na

On Wednesday, 22 May 2013 11:10:02 UTC+1, Nigel Legg wrote:
>
> Morning/Afternoon - I am new to django, and I have been working through 
> the tutorial.  I have reached Tutorial 4, 
> https://docs.djangoproject.com/en/1.5/intro/tutorial04/, which is about 
> getting the voting on the polls app to work, but when I set detail.html I 
> get an error, "
> NoReverseMatch at /polls/2/ 
>
> u'polls' is not a registered namespace
>
> What would cause that?
>
> Many thanks. 
>
> Regards,
> Nigel Legg
> 07722 652866
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>  

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




Django's cascade delete is executing the DELETE SQL twice

2013-05-22 Thread Michael
I've got an odd situation here, any idea why the delete SQL for the 
`myapp_entry_tag` table is being performed twice?

>>> from myapp.models import Tag
>>> from django.db import connection
>>> from pprint import pprint
>>> Tag.objects.only('pk').get(pk=1).delete()
>>> pprint(connection.queries)
[{u'sql': u'SELECT `myapp_tag`.`id` FROM `myapp_tag` ''WHERE 
`myapp_tag`.`id` = 1 ',
  u'time': u'0.000'},
 {u'sql': u'DELETE FROM `myapp_entry_tag` WHERE `myapp_entry_tag`.`tag_id` 
IN (1)',
  u'time': u'0.000'},
 {u'sql': u'DELETE FROM `myapp_entry_tag` WHERE `myapp_entry_tag`.`tag_id` 
IN (1)',
  u'time': u'0.000'},
 {u'sql': u'DELETE FROM `myapp_tag` WHERE `id` IN (1)', u'time': u'0.000'}]

models.py:

class Tag(models.Model):
...

class EntryTag(models.Model):
...
tag = models.ForeignKey(Tag)

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




Re: Django 1.6 Connection Pooler

2013-05-22 Thread Joe Jasinski
Thanks for that clarification. 

On Friday, May 17, 2013 2:22:14 AM UTC-5, Christophe Pettus wrote:
>
>
> On May 17, 2013, at 12:57 AM, Joe Jasinski wrote: 
>
> > So I hear that Django 1.6 will ship with a connection pooler built in, 
> which is awesome.  Does this remove the need to have a stand-alone service 
> such as pgbouncer, or am I misunderstanding how the new built-in connection 
> will work? 
>
> Aymeric can give the definitive story, but in my view it's a very handy 
> component, but doesn't (and wasn't intended to) replace a stand-alone 
> connection pooler. 
>
> The 1.6 connection pool solves the issue of Django opening a new 
> connection on each request by reusing connections at the thread level.  It 
> doesn't share connections across multiple processes in the same machine, 
> for example, nor across application servers.  For that, you need a 
> stand-alone pooler. 
>
> It also doesn't help the common problem of multiplexing a lot of potential 
> application-side connections down to the number of active server-side 
> connections that the database server can actually handle.  And, of course, 
> if you're using the advanced features of (say) pgPool II, there's a lot of 
> stuff that an app-side pool won't help. 
>
> So, it's a great and very useful feature, but a stand alone pooler 
> definitely has a role still. 
>
> -- 
> -- Christophe Pettus 
>x...@thebuild.com  
>
>

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




site critique

2013-05-22 Thread frocco
Hi Every one,

I have my PHP site up and running that I converted to django.
Would you have a look at this production site and let me know your opinions?

Current users are very fussy and resist change.

http://ntwarehouse.net 


One problem I have is SEO is not working correctly.
If I search on TIRES, my site does not show.

I am new to SEO, and have having a hard time trying to figure out what 
needs to be done.

Thanks

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




Re: define BASE_DIR?

2013-05-22 Thread Tom Evans
On Tue, May 21, 2013 at 10:08 PM, Christopher Spears
 wrote:
> I am working my way through the Django tutorial, and I have reached the part
> where I am supposed to customize the look and feel of the admin.  I am
> supposed to do that using the mysite\settings.py file (working on a Windows
> laptop).  I have two questions.
>
> At first, I just typed the following into the file:
>
> TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
>
> I got an error message stating that os.path was not recognized.  I solved
> this by putting 'import os.path' at the top of the file.  Does this mean
> there is a bug in the tutorial's documentation?  I do not recall seeing any
> instructions that told me to add this.
>
> After I solved the first problem, I now get this error message:
>
>   File "C:\Users\Chris\Documents\django_dev\mysite\mysite\settings.py", line
> 7,
> in 
> TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
> NameError: name 'BASE_DIR' is not defined
>
> Am I supposed to now define BASE_DIR?
>
> Thanks!
>

BASE_DIR is only mentioned in the tutorial from the in development
docs, which may not be the best place to start - chiefly because it
can have issues like this.

If you don't mind encountering things like this, then using the dev
docs helps find issues like this that have been added since the last
release, but if you want a more checked and correct django docs, use
the ones from the latest release.

Of course, you should always use the docs for the version that you are
actually using. I would recommend not using unreleased versions of
django to learn django though.

Cheers

Tom

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




Re: problem with ImageField does not show me the picture on a template

2013-05-22 Thread Tom Evans
On Wed, May 22, 2013 at 2:10 AM, Ronny Villarroel Mendoza
 wrote:
> Hi all,
>
> I cant show the picture that I upload from the admin site.
>
>
> settings.py:
>
> MEDIA_ROOT = '/var/www/fourweb/'
>
>
>
> models.py:
>
> class picture(models.Model):
> producto_id = models.ForeignKey(producto)
> description = models.CharField(max_length= 250)
> imagen = models.ImageField(upload_to='photos/%Y/%m/%d', help_text =
> '100px,150px')


The 'upload_to' here refers to a path relative to settings.MEDIA_ROOT,
where django will store files uploaded to this field.

> …
>{% if photos %}
> {% for photo in photos %}
>  …
> 

as we see here.

>
> the problem is that the picture doen't show, the path is broken. What I
> doing wrong ???.

As well as the things I mentioned above, Django does not serve your
media files for you, it expects that you have made additional
arrangements to serve the directory settings.MEDIA_ROOT at the url
settings.MEDIA_URL.

So:

1) Arrange for your webserver to serve static files from settings.MEDIA_ROOT
2) Set settings.MEDIA_URL to the url that you configured in step 1.

Job done.

Cheers

Tom

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




New user - template errors.

2013-05-22 Thread Nigel Legg
Morning/Afternoon - I am new to django, and I have been working through the
tutorial.  I have reached Tutorial 4,
https://docs.djangoproject.com/en/1.5/intro/tutorial04/, which is about
getting the voting on the polls app to work, but when I set detail.html I
get an error, "
NoReverseMatch at /polls/2/

u'polls' is not a registered namespace

What would cause that?

Many thanks.

Regards,
Nigel Legg
07722 652866
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg

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




IdeaScale-alike DJango applications

2013-05-22 Thread Daniele Procida
Are there any Django applications that do the same thing as 
?

IdeaScale basically seems to be a way for users to submit proposals, and have 
them voted up and down by other users; like polls, but in a web 2.1beta kind of 
way. 

It's something I've been asked about.

Any suggestions?

Daniele

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




Re: Object Lookup after Save

2013-05-22 Thread Christian Schmitt
if you want transactions you need to do :

with transaction.atomic():


like described here: 
https://docs.djangoproject.com/en/dev/topics/db/transactions/

Am Mittwoch, 22. Mai 2013 10:40:15 UTC+2 schrieb Christian Schmitt:
>
> In Django the normal behavior should be that when you do a save() it will 
> automatically commit() your query's to the database.
> so that in obj.save() you should just could access the pk with obj.idafter 
> you did a obj.save().
> If you want to maybe stop the commit you need to do a obj = 
> obj.save(commit=False), then you could add some things to your obj and 
> commit/save it later.
> But as i understood you already do a obj.save() but it doesn't commit 
> correctly? Maybe you should just try a PostgreSQL database for testing, 
> since I'm not having trouble looking up objects after i saved it.
>
> I often do things like:
> obj.save()
> return HttpResponseRedirect(reverse('view', {'pk': obj.id}))
> and i never run into any exception
>
>
> Am Dienstag, 21. Mai 2013 23:20:53 UTC+2 schrieb Chris Conover:
>>
>> Calling transaction.commit() after object.save results in 
>> a TransactionManagementError. I mentioned at the end that I am using MySQL 
>> (5.5.27). The issue is not that the Gearman workers are having trouble 
>> saving their transactions, it's that they are having trouble looking up the 
>> incoming object. I'm assuming the view and workers are separate 
>> transactions since I don't see how they could be connected -- though I'm 
>> looking into this. 
>>
>> On Tuesday, May 21, 2013 1:05:54 PM UTC-4, Tom Evans wrote:
>>>
>>> On Tue, May 21, 2013 at 4:23 PM, Chris Conover  
>>> wrote: 
>>> > Hello, 
>>> > 
>>> > I'm having an issue looking up objects immediately after they are 
>>> saved and 
>>> > am wondering if anyone has any advice on how to address the problem. 
>>> > Specifically, I'm saving an object in a view (nothing fancy, a simple 
>>> > save()) and then kicking off a Gearman task to do some operations on 
>>> that 
>>> > saved object in the background. I pass the newly created object's PK 
>>> as data 
>>> > to the Gearman worker which then does a simple 
>>> Objects.objects.get(pk=PK). 
>>> > However, almost all of the time this lookup operation fails with an 
>>> > DoesNotExist exception. I believe the problem has to do with 
>>> transactions. 
>>> > Namely, the read in the Gearman worker is happening before the write 
>>> from 
>>> > the view is committed to the database. I've tried several things 
>>> including 
>>> > refactoring the saving code to be wrapped in a 
>>> > @transaction.commit_on_success block, moving the worker submission to 
>>> > post_save and adding a long delay before the Gearman worker does the 
>>> lookup. 
>>> > Nothing really seems to solve the problem completely. Even with a 60 
>>> second 
>>> > delay, the lookup fails with some frequency. Am I missing something 
>>> here? Is 
>>> > there some Django query cache that I can clear? Or should I just 
>>> rewrite all 
>>> > this to just to use a look-back perspective. 
>>> > 
>>> > The stack is Django 1.4 connecting to MySQL 5.5.27. Django is handling 
>>> > 200-1000 requests per second and the database is handling about double 
>>> that. 
>>> > 
>>> > Thanks, 
>>> > Chris 
>>>
>>>   from django import transaction 
>>>   … 
>>>   obj.save() 
>>>   transaction.commit() 
>>>   task.submit(obj.id) 
>>>
>>> You will also need to make sure that gearman is doing things correctly 
>>> as well. You haven't mentioned what database you are using, but if 
>>> gearman's DB connection is in a read repeated mode, you can do 
>>> whatever you like in django but you won't see new data in gearman 
>>> until gearman's current transaction is committed. 
>>>
>>> Cheers 
>>>
>>> Tom 
>>>
>>

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




Re: Object Lookup after Save

2013-05-22 Thread Christian Schmitt
In Django the normal behavior should be that when you do a save() it will 
automatically commit() your query's to the database.
so that in obj.save() you should just could access the pk with obj.id after 
you did a obj.save().
If you want to maybe stop the commit you need to do a obj = 
obj.save(commit=False), then you could add some things to your obj and 
commit/save it later.
But as i understood you already do a obj.save() but it doesn't commit 
correctly? Maybe you should just try a PostgreSQL database for testing, 
since I'm not having trouble looking up objects after i saved it.

I often do things like:
obj.save()
return HttpResponseRedirect(reverse('view', {'pk': obj.id}))
and i never run into any exception


Am Dienstag, 21. Mai 2013 23:20:53 UTC+2 schrieb Chris Conover:
>
> Calling transaction.commit() after object.save results in 
> a TransactionManagementError. I mentioned at the end that I am using MySQL 
> (5.5.27). The issue is not that the Gearman workers are having trouble 
> saving their transactions, it's that they are having trouble looking up the 
> incoming object. I'm assuming the view and workers are separate 
> transactions since I don't see how they could be connected -- though I'm 
> looking into this. 
>
> On Tuesday, May 21, 2013 1:05:54 PM UTC-4, Tom Evans wrote:
>>
>> On Tue, May 21, 2013 at 4:23 PM, Chris Conover  wrote: 
>> > Hello, 
>> > 
>> > I'm having an issue looking up objects immediately after they are saved 
>> and 
>> > am wondering if anyone has any advice on how to address the problem. 
>> > Specifically, I'm saving an object in a view (nothing fancy, a simple 
>> > save()) and then kicking off a Gearman task to do some operations on 
>> that 
>> > saved object in the background. I pass the newly created object's PK as 
>> data 
>> > to the Gearman worker which then does a simple 
>> Objects.objects.get(pk=PK). 
>> > However, almost all of the time this lookup operation fails with an 
>> > DoesNotExist exception. I believe the problem has to do with 
>> transactions. 
>> > Namely, the read in the Gearman worker is happening before the write 
>> from 
>> > the view is committed to the database. I've tried several things 
>> including 
>> > refactoring the saving code to be wrapped in a 
>> > @transaction.commit_on_success block, moving the worker submission to 
>> > post_save and adding a long delay before the Gearman worker does the 
>> lookup. 
>> > Nothing really seems to solve the problem completely. Even with a 60 
>> second 
>> > delay, the lookup fails with some frequency. Am I missing something 
>> here? Is 
>> > there some Django query cache that I can clear? Or should I just 
>> rewrite all 
>> > this to just to use a look-back perspective. 
>> > 
>> > The stack is Django 1.4 connecting to MySQL 5.5.27. Django is handling 
>> > 200-1000 requests per second and the database is handling about double 
>> that. 
>> > 
>> > Thanks, 
>> > Chris 
>>
>>   from django import transaction 
>>   … 
>>   obj.save() 
>>   transaction.commit() 
>>   task.submit(obj.id) 
>>
>> You will also need to make sure that gearman is doing things correctly 
>> as well. You haven't mentioned what database you are using, but if 
>> gearman's DB connection is in a read repeated mode, you can do 
>> whatever you like in django but you won't see new data in gearman 
>> until gearman's current transaction is committed. 
>>
>> Cheers 
>>
>> Tom 
>>
>

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




Re: Understanding Django transactions

2013-05-22 Thread Christophe Pettus

On May 21, 2013, at 12:43 PM, Aymeric Augustin wrote:
> Anyway, in this scenario, `atomic` will work as expected. When autocommit is 
> off, you're always in a transaction, and as a consequence `atomic` uses 
> savepoints to guarantee atomicity; it'll never commit. You have to call 
> transaction.commit() at some point to save changes.

Just to clarify, `atomic` will commit in this scenario:

with atomic:
   my_model_object.save()

You don't have to explicitly call transaction.commit() to issue a commit after 
the .save(), correct?

--
-- Christophe Pettus
   x...@thebuild.com

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