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 #1931 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

[Patch] It should not be necessary to subclass AppConfig just to defined custom paths

Reported by: Gustavo Owned by: anonymous
Priority: high Milestone:
Component: TurboGears Version: trunk
Severity: major Keywords:
Cc:

Description

We should not  subclass AppConfig just to set custom paths to the controllers, for example. It should be possible to set these paths as attributes of base_config in app_cfg.py:

root = path.dirname(path.abspath(__file__))
base_config.paths = Bunch()
base_config.paths.controllers = path.join(root, 'web', 'controllers')

The attached path would solve this.

Attachments

tg-1931.patch Download (1.1 KB) - added by Gustavo 11 years ago.
The updated patch

Change History

comment:1 follow-up: ↓ 2 Changed 11 years ago by alberto

Looks good to me, though perhaps the 'paths' Bunch could be pre-initialized in AppConfig?'s constructor with the defaults so it doesn't need to be imported from app_cfg.py so it's lss burden on the user.

Alberto

comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 11 years ago by Gustavo

Replying to alberto:

Looks good to me, though perhaps the 'paths' Bunch could be pre-initialized in AppConfig?'s constructor with the defaults so it doesn't need to be imported from app_cfg.py so it's lss burden on the user.

+1. Do you want me to update the patch to implement that?

comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 11 years ago by alberto

Replying to Gustavo:

Replying to alberto:

Looks good to me, though perhaps the 'paths' Bunch could be pre-initialized in AppConfig?'s constructor with the defaults so it doesn't need to be imported from app_cfg.py so it's lss burden on the user.

+1. Do you want me to update the patch to implement that?

I wouldn't have mentioned it otheriwise... ;) If you also think it's a good idea and it seems feasible then go ahead, sure.

Alberto

Changed 11 years ago by Gustavo

The updated patch

comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 11 years ago by Gustavo

Replying to alberto:

Replying to Gustavo:

Replying to alberto:

Looks good to me, though perhaps the 'paths' Bunch could be pre-initialized in AppConfig?'s constructor with the defaults so it doesn't need to be imported from app_cfg.py so it's lss burden on the user.

+1. Do you want me to update the patch to implement that?

I wouldn't have mentioned it otheriwise... ;) If you also think it's a good idea and it seems feasible then go ahead, sure.

OK, I've updated the patch accordingly. However, I think that setup_paths() is not required anymore and thus I'll send an alternate patch for this approach...

comment:5 in reply to: ↑ 4 Changed 11 years ago by Gustavo

However, I think that setup_paths() is not required anymore and thus I'll send an alternate patch for this approach...

Nah, it's not possible because the package attribute is not available in the constructor, so the updated patch is the final one.

comment:6 Changed 11 years ago by mramm

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

comment:7 Changed 11 years ago by mramm

  • Milestone set to 2.0-preview-3

comment:8 Changed 10 years ago by anonymous

  • Milestone 1.9.7a4 deleted

Milestone 1.9.7a4 deleted

Note: See TracTickets for help on using tickets.