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 -~----------~----~----~----~------~----~------~--~---