Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8150

Re: Using django ORM from web browser and from command line apps

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '21,': 0.09; 'consume': 0.09; 'controlled': 0.09; 'decorator': 0.09; 'enabled.': 0.09; 'runtime': 0.09; 'subject:django': 0.09; 'tasks,': 0.09; 'pm,': 0.10; 'scripts': 0.10; 'wrote:': 0.14; 'intended.': 0.16; 'subject:command': 0.16; 'sure,': 0.16; 'url:db': 0.16; 'tue,': 0.17; 'issue,': 0.19; 'script.': 0.19; 'cheers,': 0.19; 'command': 0.19; 'header:In-Reply-To:1': 0.21; 'commit': 0.22; 'request,': 0.22; 'memory': 0.22; 'received:209.85.161.46': 0.23; 'received :mail-fx0-f46.google.com': 0.23; 'received:209.85.161': 0.26; 'script': 0.27; "i'm": 0.27; 'message-id:@mail.gmail.com': 0.28; 'subject:web': 0.29; 'enabled,': 0.30; 'performs': 0.30; 'yes.': 0.30; 'hi,': 0.31; 'django': 0.31; 'this.': 0.31; 'does': 0.33; 'to:addr:python-list': 0.33; 'normally': 0.34; 'there': 0.35; 'quite': 0.36; 'considered': 0.36; 'certain': 0.36; 'probably': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'http': 0.37; 'url:docs': 0.37; 'url:en': 0.37; 'case': 0.37; 'perform': 0.37; 'could': 0.38; 'subject:from': 0.38; 'subject:: ': 0.38; 'some': 0.38; "i'd": 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'really': 0.40; 'happen': 0.60; 'custom': 0.60; 'browser': 0.62; 'huge': 0.62; 'here': 0.66; 'special': 0.66; 'url:3': 0.67; 'imagine': 0.72; 'subject:line': 0.73; 'transactions': 0.80; 'news123': 0.84; 'subject:apps': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=W9u5Uy1SkDv4w3wz7LCS9aOkMuzYARZuYwlvIbwA6X4=; b=KvYZGxLI+vErdftK23YWL3k7k9ucYo0AtwQ12Jt7FLIOn4RswwQc/PlzT9egGsvi/d oifGpSnOCGIhucNaySbktvor5DR2zu8m2k9Ph8OmEj/2SnlHFQlPcL16z4ixm6fICF8s voNHABmdNI4VovXLvpqZC4c3V1LGAz6NtOREU=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=HcbkFGL/xPH/EDKPKn/nFj0BV29/pHhgV/7l3NgB+bAbakOvP2RZV72cN+7J+P2yS6 JOio78C3FpzSoRh9EWJ3VsCm94s09L9AkEfWi3fp7BGxMP2Zoj1NfcBK0SyYFD+h1/Lu K4VEHez/gbnB+eFRsDCCRQ1UoZ5phGj9PYSUs=
MIME-Version 1.0
In-Reply-To <4e012bc4$0$1555$426a74cc@news.free.fr>
References <4e012bc4$0$1555$426a74cc@news.free.fr>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Tue, 21 Jun 2011 18:09:59 -0600
Subject Re: Using django ORM from web browser and from command line apps
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.257.1308701430.1164.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 82.94.164.166
X-Trace 1308701430 news.xs4all.nl 49181 [::ffff:82.94.164.166]:41535
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8150

Show key headers only | View raw


On Tue, Jun 21, 2011 at 5:39 PM, News123 <news1234@free.fr> wrote:
> Hi,
>
> I'm having a django browser application.
>
> There's certain administrative tasks, that I'd like to perform from the
> command line (cronjob or manually).
> As these scripts might be huge and might consume quite some memory I'd
> prefer, that they were not part of the normal application and would just
> consume memory during the administrative phase.
>
> I am not sure, whether this is a use case really being intended.

It sounds like you probably want a custom management command:

https://docs.djangoproject.com/en/1.3/howto/custom-management-commands/

> I wanted to know whether there are any precautions to take if I do this.
>
> The one issue, that I could imagine is that Django (if I understood
> correctly) performs normally database transaction based an a http request.

If you have the TransactionMiddleware enabled, yes.  Otherwise the
default is to commit everything immediately.

> What would happen if I don't do anythong special in a script.
> Would the entire runtime of the script be considered a transaction?

The default here is also to commit everything immediately.  Since
there is no HTTP request, the TransactionMiddleware does not get
invoked even if enabled.  For controlled transactions you will need to
use the commit_on_success or commit_manually decorator /
context-managers:

https://docs.djangoproject.com/en/1.3/topics/db/transactions/

Cheers,
Ian

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Using django ORM from web browser and from command line apps News123 <news1234@free.fr> - 2011-06-22 01:39 +0200
  Re: Using django ORM from web browser and from command line apps Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-21 18:09 -0600
    Re: Using django ORM from web browser and from command line apps News123 <news1234@free.fr> - 2011-06-22 02:21 +0200
      Re: Using django ORM from web browser and from command line apps Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-21 19:08 -0600
        Re: Using django ORM from web browser and from command line apps News123 <news1234@free.fr> - 2011-06-22 03:18 +0200
      Re: Using django ORM from web browser and from command line apps "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2011-06-22 03:57 -0700

csiph-web