Django

Code

Ticket #13055 (closed: fixed)

Opened 5 months ago

Last modified 5 months ago

Transaction decorators / multiple databases : using=

Reported by: olb@nebkha.net Assigned to: nobody
Milestone: 1.2 Component: Database layer (models, ORM)
Version: SVN Keywords: transaction decorators
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Documentation tells transaction decorators can be used with multiple databases :

    @commit_on_success(using='db_alias')
    def func(request):
        ...

Doing like that raises an error and it seems that django code is actually written to work as follow :

    @commit_on_success('db_alias')
    def func(request):
        ...

Attachments

Change History

03/08/10 13:09:42 changed by kmtracey

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

autocommit, commit_on_success, and commit_manually all have their one kwarg specified as func_or_using, not using as per the doc.

03/08/10 14:40:05 changed by ubernostrum

Is there a reason why it's not just using everywhere (since all the other transaction-management functions take it as using)? We don't provide any documentation for passing a function there or explaining why you'd want to do that, and from the code I can't figure out what that feature's useful for...

03/08/10 17:48:53 changed by russellm

This is an example of internal implementation leaking to the external API. The argument is called 'func_or_using' because @transaction and @transaction('my_alias') are both allowed forms. The first case is required for backwards compatibility, and it's that case where you are providing a function.

Practicality should trump the purity of internal variable naming; we should change the argument to 'using', and document the weirdness internally.

03/10/10 07:13:58 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [12752]) Fixed #13055 -- Cleaned up the implementation of transaction decorators to provide a consistent external facing API. Thanks to olb@nebkha.net for the report.


Add/Change #13055 (Transaction decorators / multiple databases : using=)




Change Properties
Action