Re: Transaction commit with cursor.execute
> When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. So it is, my bad, thank you againg. You see, it seemed a little weird, that first (with the decorator) we force transaction to commit manually to use 'test' for all that would happen in our view (suppose that all commits in view should share that 'using' from the decorator), and then explicitly tell the transaction to commit again with 'using'. But if we have transactions to different DBs in one view that seems logical. On 29 апр, 13:16, Russell Keith-Magee wrote: > On Thu, Apr 29, 2010 at 12:20 PM, idle sign wrote: > > I'm using the latest trunk fromhttp://github.com/django/django. > > A complete test project you can grab > > athttp://idlesign.narod.ru/django/django-tests.tar.gz > > There is a little bootstrap.sh to run to create DBs. > > > Thank you, Russ. > > Ok - using your test application as provided, I see the "This code > isn't under transaction management" error. That's because line 7 of > views.py (the decorator that enables transaction management) is > commented out. When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. > > I take it you seeing something different? > > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Transaction commit with cursor.execute
> When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. So it is, my bad, thank you againg. You see, it seemed a little weird, that first (with the decorator) we force transaction to commit manually to 'test' all that would happen in our view (suppose that all commits in view should share that 'using' from the decorator), and then explicitly tell the transaction to commit again with 'using'. But if we have transactions to different DBs in one view that seems logical. On 29 апр, 13:16, Russell Keith-Magee wrote: > On Thu, Apr 29, 2010 at 12:20 PM, idle sign wrote: > > I'm using the latest trunk fromhttp://github.com/django/django. > > A complete test project you can grab > > athttp://idlesign.narod.ru/django/django-tests.tar.gz > > There is a little bootstrap.sh to run to create DBs. > > > Thank you, Russ. > > Ok - using your test application as provided, I see the "This code > isn't under transaction management" error. That's because line 7 of > views.py (the decorator that enables transaction management) is > commented out. When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. > > I take it you seeing something different? > > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Transaction commit with cursor.execute
> When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. So it is, my bad, Russ, thank you againg. You see, it seemed a little weird, that first (with the decorator) we force transaction to commit manually to 'test' all that would happen in our view (suppose that all commits in view should share that 'using' from the decorator), and then explicitly tell the transaction to commit again with 'using'. But if we have transactions to different DBs in one view that seems logical. On 29 апр, 13:16, Russell Keith-Magee wrote: > On Thu, Apr 29, 2010 at 12:20 PM, idle sign wrote: > > I'm using the latest trunk fromhttp://github.com/django/django. > > A complete test project you can grab > > athttp://idlesign.narod.ru/django/django-tests.tar.gz > > There is a little bootstrap.sh to run to create DBs. > > > Thank you, Russ. > > Ok - using your test application as provided, I see the "This code > isn't under transaction management" error. That's because line 7 of > views.py (the decorator that enables transaction management) is > commented out. When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. > > I take it you seeing something different? > > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Transaction commit with cursor.execute
On Thu, Apr 29, 2010 at 12:20 PM, idle sign wrote: > I'm using the latest trunk from http://github.com/django/django. > A complete test project you can grab at > http://idlesign.narod.ru/django/django-tests.tar.gz > There is a little bootstrap.sh to run to create DBs. > > Thank you, Russ. Ok - using your test application as provided, I see the "This code isn't under transaction management" error. That's because line 7 of views.py (the decorator that enables transaction management) is commented out. When line 7 is uncommented, transaction management is enabled, and the view works as I would expect. I take it you seeing something different? 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-us...@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: Transaction commit with cursor.execute
I'm using the latest trunk from http://github.com/django/django. A complete test project you can grab at http://idlesign.narod.ru/django/django-tests.tar.gz There is a little bootstrap.sh to run to create DBs. Thank you, Russ. On 29 апр, 10:16, Russell Keith-Magee wrote: > On Thu, Apr 29, 2010 at 11:04 AM, idle sign wrote: > > I thought so, have tried so, but got "This code isn't under > > transaction management", and opened this thread :) > > I get that error if I *omit* the using= argument to commit (which is > what I'd expect to see). > > What version of trunk are you using? There have been a couple of > bugfixes to the commit decorators since the beta, and it's possibly > you might be tripping over one of them. > > Failing that - I can only assume there is something unusual with your > database or router setup that is causing a complication. I'd need to > see specifics (for example, a complete test project) to verify if > there is something else 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Transaction commit with cursor.execute
On Thu, Apr 29, 2010 at 11:04 AM, idle sign wrote: > I thought so, have tried so, but got "This code isn't under > transaction management", and opened this thread :) I get that error if I *omit* the using= argument to commit (which is what I'd expect to see). What version of trunk are you using? There have been a couple of bugfixes to the commit decorators since the beta, and it's possibly you might be tripping over one of them. Failing that - I can only assume there is something unusual with your database or router setup that is causing a complication. I'd need to see specifics (for example, a complete test project) to verify if there is something else 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-us...@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: Transaction commit with cursor.execute
I thought so, have tried so, but got "This code isn't under transaction management", and opened this thread :) Environment: Request Method: GET Request URL: http://localhost:8000/ Django Version: 1.2 beta 1 Python Version: 2.6.4 Installed Applications: ['testapp'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') Traceback: File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response 100. response = callback(request, *callback_args, **callback_kwargs) File "/home/idle/projects/gitdev/django-tests/testapp/views.py" in test 22. transaction.commit(using='test') File "/usr/lib/python2.6/dist-packages/django/db/transaction.py" in commit 200. set_clean(using=using) File "/usr/lib/python2.6/dist-packages/django/db/transaction.py" in set_clean 125. raise TransactionManagementError("This code isn't under transaction management") Exception Type: TransactionManagementError at / Exception Value: This code isn't under transaction management On 29 апр, 09:07, Russell Keith-Magee wrote: > On Thu, Apr 29, 2010 at 12:59 AM, idle sign wrote: > > I think I spotted something weird. May be someone could explain that? > > > 1. In Django 1.2 define two DBs (let it be sqlite), one of which name > > 'test'. > > 2. Define DB router for 'testapp' so that it always uses 'test' DB. > > 3. Use 'commit_manually' decorator for 'test' view. > > 4. In 'test' view define 'cursor' pointing to 'test' DB. > > 5. Execute some INSERTs and commit > > *. 'Samples' object (exported from model) would show all inserted > > object, but nothing would be written into DB. > > The problem is on this line: > > > transaction.commit() > > By default (for backwards compatibility), commit() operates on the > default database. If you want to commit results on the 'test' > connection, you need to provide a 'using' argument: > > transaction.commit(using='test') > > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Transaction commit with cursor.execute
On Thu, Apr 29, 2010 at 12:59 AM, idle sign wrote: > I think I spotted something weird. May be someone could explain that? > > 1. In Django 1.2 define two DBs (let it be sqlite), one of which name > 'test'. > 2. Define DB router for 'testapp' so that it always uses 'test' DB. > 3. Use 'commit_manually' decorator for 'test' view. > 4. In 'test' view define 'cursor' pointing to 'test' DB. > 5. Execute some INSERTs and commit > *. 'Samples' object (exported from model) would show all inserted > object, but nothing would be written into DB. The problem is on this line: > transaction.commit() By default (for backwards compatibility), commit() operates on the default database. If you want to commit results on the 'test' connection, you need to provide a 'using' argument: transaction.commit(using='test') 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-us...@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.
Transaction commit with cursor.execute
I think I spotted something weird. May be someone could explain that? 1. In Django 1.2 define two DBs (let it be sqlite), one of which name 'test'. 2. Define DB router for 'testapp' so that it always uses 'test' DB. 3. Use 'commit_manually' decorator for 'test' view. 4. In 'test' view define 'cursor' pointing to 'test' DB. 5. Execute some INSERTs and commit *. 'Samples' object (exported from model) would show all inserted object, but nothing would be written into DB. @transaction.commit_manually(using='test') def test(request): print Samples.objects.all() cursor = connections['test'].cursor() cursor.execute("PRAGMA temp_store=MEMORY") cursor.execute("PRAGMA synchronous=OFF") for i in range(1, 25): cursor.execute("INSERT INTO testapp_samples (simplefield) VALUES (%s);", [i]) transaction.commit() print Samples.objects.all() raise Http404 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: transaction commit
On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: > > Nimrod, > > NAA> On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: > >> >> Yes, I read carefuly your question and thought the answer was > >> >> straighforward. I don't understand why you don't want decorators, > but you > >> >> could just check the decorator definition to read what it does and copy > >> >> it's code. All you need is decorator name and grep over django > sources :) > >> > NAA> Aren't decorators usable only in views? > >> > >> Decorators are python feature. Django views are regular functions, just > as > >> any other. > > NAA> Sorry I wasn't very clear on that last message, I meant the Django > NAA> db.transactions decorator functions. I am thinking they only work when > NAA> you use them in a view. When you try to use them elsewhere, e.g. a > NAA> Django-based command line app, see below... > > No, you're wrong. Transaction decorators work not only in view functions. > They work anywhere in the web app, provided transaction middleware is > included. Ah, there we go :) but that's for web apps, though I must admit that I have never really tried adding decorators to non-view methods. But now that you mention it, I have a few non-view method call that need it. So thanks for pointing that out. After mucking around in the Django sources, I eventually figured out that I needed the calls to enter_transaction_management() and friends from within the command line app. > NAA> At least that's what I think. I have a project that required a > NAA> separately running process (running as daemon) that needed access to > NAA> the Django models. Since the code in the daemon is not run in the > NAA> context of a view (no triggering of TransactionMiddleware), > NAA> transactions decorators do not work. I get: > >> > NAA> TransactionManagementError: This code isn't under transaction management > >> > >> Not having read transaction code, can't say what haven't worked in your > >> case. Definitely, something wasn't initialized :) > > NAA> You're right. The app I am talking about is not a web app, rather a > NAA> command line app that I made as a supplement to the web app I made > NAA> using Django. Since it makes no sense to reinvent the wheel, I just > NAA> used Django's ORM system in the command line app. When I tried using > NAA> transactions using the transaction decorator functions I get the error > NAA> above. Likely cause is that the command line app is not using > NAA> middleware, ergo not using TransactionMiddleware, then I needed a way > NAA> to initialize and manage transactions manually. > > A ticket in my queue is similar, so I understand you perfectly. > > Quick glance on django.middleware.transaction shows: > > def process_request(self, request): > """Enters transaction management""" > transaction.enter_transaction_management() > transaction.managed(True) > > def process_exception(self, request, exception): > """Rolls back the database and leaves transaction management""" > if transaction.is_dirty(): > transaction.rollback() > transaction.leave_transaction_management() > > def process_response(self, request, response): > """Commits and leaves transaction management.""" > if transaction.is_managed(): > if transaction.is_dirty(): > transaction.commit() > transaction.leave_transaction_management() > return response > > So in cmd line app you have to call >transaction.enter_transaction_management() >transaction.managed(True) > in initialization and >transaction.leave_transaction_management() > in the end. Not tested, but should work. > > -- > Andrey V Khavryuchenko > Django NewGate - http://www.kds.com.ua/djiggit/ > Development - http://www.kds.com.ua > Call akhavr1975 on www.gizmoproject.com > > > > -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
Nimrod, NAA> On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: >> >> Yes, I read carefuly your question and thought the answer was >> >> straighforward. I don't understand why you don't want decorators, but >> >> you >> >> could just check the decorator definition to read what it does and copy >> >> it's code. All you need is decorator name and grep over django sources >> >> :) >> NAA> Aren't decorators usable only in views? >> >> Decorators are python feature. Django views are regular functions, just as >> any other. NAA> Sorry I wasn't very clear on that last message, I meant the Django NAA> db.transactions decorator functions. I am thinking they only work when NAA> you use them in a view. When you try to use them elsewhere, e.g. a NAA> Django-based command line app, see below... No, you're wrong. Transaction decorators work not only in view functions. They work anywhere in the web app, provided transaction middleware is included. NAA> At least that's what I think. I have a project that required a NAA> separately running process (running as daemon) that needed access to NAA> the Django models. Since the code in the daemon is not run in the NAA> context of a view (no triggering of TransactionMiddleware), NAA> transactions decorators do not work. I get: >> NAA> TransactionManagementError: This code isn't under transaction management >> >> Not having read transaction code, can't say what haven't worked in your >> case. Definitely, something wasn't initialized :) NAA> You're right. The app I am talking about is not a web app, rather a NAA> command line app that I made as a supplement to the web app I made NAA> using Django. Since it makes no sense to reinvent the wheel, I just NAA> used Django's ORM system in the command line app. When I tried using NAA> transactions using the transaction decorator functions I get the error NAA> above. Likely cause is that the command line app is not using NAA> middleware, ergo not using TransactionMiddleware, then I needed a way NAA> to initialize and manage transactions manually. A ticket in my queue is similar, so I understand you perfectly. Quick glance on django.middleware.transaction shows: def process_request(self, request): """Enters transaction management""" transaction.enter_transaction_management() transaction.managed(True) def process_exception(self, request, exception): """Rolls back the database and leaves transaction management""" if transaction.is_dirty(): transaction.rollback() transaction.leave_transaction_management() def process_response(self, request, response): """Commits and leaves transaction management.""" if transaction.is_managed(): if transaction.is_dirty(): transaction.commit() transaction.leave_transaction_management() return response So in cmd line app you have to call transaction.enter_transaction_management() transaction.managed(True) in initialization and transaction.leave_transaction_management() in the end. Not tested, but should work. -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua Call akhavr1975 on www.gizmoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
Hello Andrey, > NAA> On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: > >> Yes, I read carefuly your question and thought the answer was > >> straighforward. I don't understand why you don't want decorators, but > you > >> could just check the decorator definition to read what it does and copy > >> it's code. All you need is decorator name and grep over django sources :) > > NAA> Aren't decorators usable only in views? > > Decorators are python feature. Django views are regular functions, just as > any other. Sorry I wasn't very clear on that last message, I meant the Django db.transactions decorator functions. I am thinking they only work when you use them in a view. When you try to use them elsewhere, e.g. a Django-based command line app, see below... > NAA> At least that's what I think. I have a project that required a > NAA> separately running process (running as daemon) that needed access to > NAA> the Django models. Since the code in the daemon is not run in the > NAA> context of a view (no triggering of TransactionMiddleware), > NAA> transactions decorators do not work. I get: > > NAA> TransactionManagementError: This code isn't under transaction management > > Not having read transaction code, can't say what haven't worked in your > case. Definitely, something wasn't initialized :) You're right. The app I am talking about is not a web app, rather a command line app that I made as a supplement to the web app I made using Django. Since it makes no sense to reinvent the wheel, I just used Django's ORM system in the command line app. When I tried using transactions using the transaction decorator functions I get the error above. Likely cause is that the command line app is not using middleware, ergo not using TransactionMiddleware, then I needed a way to initialize and manage transactions manually. -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
NAA> On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: >> Yes, I read carefuly your question and thought the answer was >> straighforward. I don't understand why you don't want decorators, but you >> could just check the decorator definition to read what it does and copy >> it's code. All you need is decorator name and grep over django sources :) NAA> Aren't decorators usable only in views? Decorators are python feature. Django views are regular functions, just as any other. NAA> At least that's what I think. I have a project that required a NAA> separately running process (running as daemon) that needed access to NAA> the Django models. Since the code in the daemon is not run in the NAA> context of a view (no triggering of TransactionMiddleware), NAA> transactions decorators do not work. I get: NAA> TransactionManagementError: This code isn't under transaction management Not having read transaction code, can't say what haven't worked in your case. Definitely, something wasn't initialized :) -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua Call akhavr1975 on www.gizmoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
Hello everyone, On 7/25/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: > Yes, I read carefuly your question and thought the answer was > straighforward. I don't understand why you don't want decorators, but you > could just check the decorator definition to read what it does and copy > it's code. All you need is decorator name and grep over django sources :) Aren't decorators usable only in views? At least that's what I think. I have a project that required a separately running process (running as daemon) that needed access to the Django models. Since the code in the daemon is not run in the context of a view (no triggering of TransactionMiddleware), transactions decorators do not work. I get: TransactionManagementError: This code isn't under transaction management So being able to use transactions manually would be useful. -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
On 7/25/07, Peter Melvyn <[EMAIL PROTECTED]> wrote: > > > Your example is correct, and you aren't violating any 'Django principles'. > > Really? Should not be there something like this? Yes - this is a more complete example, and catching the rollback case is a good idea. The point I was trying to make is that manually invoking commit is both legal and encouraged when appropriate. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
Michal, MK> I suppose you read my question attentively and therefore you know that MK> I searched the web (and django documentation of course including the MK> transaction page). And I suppose you know that I was looking for MK> example how to use transactions without decorators. MK> The problem is that there's no example how to use transactions without MK> decorators in the documentation, there's no example here in this MK> mailing list... I found the example in MK> django.db.transaction.py Yes, I read carefuly your question and thought the answer was straighforward. I don't understand why you don't want decorators, but you could just check the decorator definition to read what it does and copy it's code. All you need is decorator name and grep over django sources :) MK> But thanks anyway ;-) Luck! -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua Call akhavr1975 on www.gizmoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
> Your example is correct, and you aren't violating any 'Django principles'. Really? Should not be there something like this? enter_transaction_management() try: managed(True) try: ... except: transaction.rollback() raise ... else: transaction.commit() finally: leave_transaction_management() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
OK, I can try it but it will require a correction because I'm not a native speaker. Michal On 24/07/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > On 7/24/07, Michal Konvalinka <[EMAIL PROTECTED]> wrote: > > > > The problem is that there's no example how to use transactions without > > decorators in the documentation, there's no example here in this > > mailing list... I found the example in > > django.db.transaction.py > > This is a problem that should be fixed. Please log a ticket to report > this lack of documentation. If you're feeling really adventurous, try > your hand at writing the missing section. We welcome any contribution, > and documentation from newcomers is often quite useful (since it > highlights the areas that seem obvious to us, but aren't). > > Many thanks, > Russ Magee %-) > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
On 7/24/07, Michal Konvalinka <[EMAIL PROTECTED]> wrote: > > The problem is that there's no example how to use transactions without > decorators in the documentation, there's no example here in this > mailing list... I found the example in > django.db.transaction.py This is a problem that should be fixed. Please log a ticket to report this lack of documentation. If you're feeling really adventurous, try your hand at writing the missing section. We welcome any contribution, and documentation from newcomers is often quite useful (since it highlights the areas that seem obvious to us, but aren't). Many thanks, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
Hi Andrey, I suppose you read my question attentively and therefore you know that I searched the web (and django documentation of course including the transaction page). And I suppose you know that I was looking for example how to use transactions without decorators. The problem is that there's no example how to use transactions without decorators in the documentation, there's no example here in this mailing list... I found the example in django.db.transaction.py But thanks anyway ;-) Michal On 24/07/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: > > > MK> Hi, > MK> I would like to use transactions (in MySQL and InnoDB). I know there > MK> are decorators but I don't want to use them now. Is there any example > MK> how to use transactions without decorators? I couldn't find anything > MK> on django website, this user-group... > > Quick google on "django transactions" shows > http://www.djangoproject.com/documentation/transactions/ as the first > result. > > And it has a cut down example of manual commit usage. > > -- > Andrey V Khavryuchenko > Django NewGate - http://www.kds.com.ua/djiggit/ > Development - http://www.kds.com.ua > Call akhavr1975 on www.gizmoproject.com > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
MK> Hi, MK> I would like to use transactions (in MySQL and InnoDB). I know there MK> are decorators but I don't want to use them now. Is there any example MK> how to use transactions without decorators? I couldn't find anything MK> on django website, this user-group... Quick google on "django transactions" shows http://www.djangoproject.com/documentation/transactions/ as the first result. And it has a cut down example of manual commit usage. -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua Call akhavr1975 on www.gizmoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: transaction commit
On 7/24/07, Michal Konvalinka <[EMAIL PROTECTED]> wrote: > It works but I would like to ask If I am violating some Django > principles or not. Your example is correct, and you aren't violating any 'Django principles'. Django provides decorators because it can be convenient to wrap a whole function as a transaction. However, that's not the way _all_ code needs to work, so the manual mechanisms (which you have discovered) also exist. Feel free to use whatever mechanism suits your needs. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
transaction commit
Hi, I would like to use transactions (in MySQL and InnoDB). I know there are decorators but I don't want to use them now. Is there any example how to use transactions without decorators? I couldn't find anything on django website, this user-group... Is this correct? def update_something(self, pairs): from django.db import connection, transaction transaction.enter_transaction_management() cursor = connection.cursor() for pair in pairs: Q = '''UPDATE `table` SET `something` = %s WHERE `id` = %s''' cursor.execute(Q, (pair['something'], pair['id'])) transaction.commit() transaction.leave_transaction_management() It works but I would like to ask If I am violating some Django principles or not. Thank you, Michal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---