| 20 | From Trac 0.12 {{{env.get_repository()}}} is deprecated, replaced by the {{{RepositoryManager}}} interface. The above code becomes: |
| 21 | {{{ |
| 22 | #!python |
| 23 | from trac.env import Environment |
| 24 | from trac.versioncontrol import RepositoryManager |
| 25 | |
| 26 | env = Environment('/path/to/projenv') |
| 27 | repos = RepositoryManager(env).get_repository(None) |
| 28 | try: |
| 29 | # Do whatever you like with the repository object here |
| 30 | finally: |
| 31 | repos.close() |
| 32 | }}} |
| 33 | |
| 34 | To access a repository other than the default pass a {{{reponame}}} in place of {{{None}}}. In class that inherits from {{{Component}}} it is more convenient to use {{{self.env}}} than instantiate {{{Environment}}} manually. |