Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13747 closed (fixed)

Post 1.2 Development code wrongly included in 1.2 doc on Custom Management Commands

Reported by: metamemetics Owned by: nobody
Component: Documentation Version: 1.2
Severity: Keywords: Custom Management Commands
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

http://docs.djangoproject.com/en/1.2/howto/custom-management-commands/

The last line of the 2nd example code block is:

self.stdout.write('Successfully closed poll "%s"\n' % poll_id)

This will not work unless you are using a development repository from within the last week, or else you will get the error 'Command' object has no attribute 'stdout'. Since it is a fairly recent addition I assume it should be only in the development documentation and not the 1.2 documentation.

Attachments (0)

Change History (5)

comment:1 Changed 4 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [13364]) [1.2.X] Fixed #13747 -- Reverted documentation suggesting the use of self.stdout/err in management commands in 1.2. Thanks to metamemetics for the report.

Strictly, self.stdout/err is a feature addition; however, it's a
feature that is required in order to achieve a massive speedup in the
tests and to maintain parity between 1.2.X and trunk tests. However,
the feature is completely transparent -- the old technique will work
fine, it just isn't as testable. Therefore, we'll treat this as an
undocumented feature in the 1.2 branch.

comment:3 Changed 4 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

IMO this feature addition should be marked as added in 1.2, since the doc says you should use it: "When you are using management commands and wish to provide console output, you should write to self.stdout and self.stderr, instead of printing to stdout and stderr directly."

comment:4 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

No, the docs really don't say that (any more). As of [13364], that text was removed from the 1.2 documentation. However, it still exists in the "dev" documentation, which reflects the current state of trunk.

comment:5 Changed 4 years ago by kmtracey

Perhaps the anonymous re-opener meant to say it should be marked as added in 1.3? I have not checked to be sure, but it sounds like now the problem may be that reading the dev documentation there is no indication ("new in development") that this advice cannot be followed if you are running the current official release?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.