Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2141 (closed defect: fixed)

Opened 8 years ago

Last modified 8 years ago

commands.py file conflicts with python standard library

Reported by: zafy Owned by: faide
Priority: normal Milestone: 1.1
Component: TurboGears Version: 1.0.8
Severity: normal Keywords:


When using tg-admin quickstart, a commands.py file is generated inside the project directory. This file conflicts with the commands module from the python standard lib and causes obvious import issues. I renamed it as commands_tg.py and changed the name accordingly in setup.py and everything works fine again.

Change History

comment:1 Changed 8 years ago by Chris Arndt

There should be no problem if you always import the commands module from your app with "import yourpkg.commands" or "from yourpkg import commands". This is one reason why namespace support in Python is so useful.

Besides the commands module from the standard library is no more in Python 3.0.

I'm tempted to close this a invalid. Maybe you should give specific examples of issues you encountered?

comment:2 Changed 8 years ago by zafy

Mark Ramm asked me to open the ticket so I did, I really asked whether it was a normal or not in the mailing list :  http://groups.google.com/group/turbogears/browse_thread/thread/aa5b20404016666d However the problem is not to import the commands module from my app, but to import the one from the standard library. If I do : import commands I import the commands module that was generated by TG, when really I was trying to import the python commands module to use its getstatusoutput method. Hope this makes sense now, sorry if I was a bit vague before.

comment:3 Changed 8 years ago by Chris Arndt

Arguably, with Python >= 2.4 (2.3 is not supported by TG >= 1.1) you could use the subprocess module for everything that the commands module does, but I guess third-party code that uses commands might still break because of the name conflict.

I don't like the name commands_tg.py though, it goes against PEP8 naming rules and the module contents are not really TG specific, the general pattern could be used for all kinds of command line commands your app supplies.

Any suggestions for a better module name anyone?

comment:4 Changed 8 years ago by chrisz

Why not rename it to "command" (singular)? This name is also used in the turbogears package.

comment:5 Changed 8 years ago by Chris Arndt

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

Fixed in r6635 following chrisz's suggestion.

Note: See TracTickets for help on using tickets.