Edgewall Software
Modify

Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#11982 closed enhancement (fixed)

Remove dependency on ConfigObj

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.1.5
Component: general Version:
Severity: normal Keywords: authzpolicy configobj config
Cc: Branch:
Release Notes:

Removed dependency on ConfigObj. The package was previously needed by AuthzPolicy.

API Changes:

Added OrderedDict to trac.util.compat module for Python 2.6 compatibility.

Internal Changes:

Description

It seems like the dependency on ConfigObj in tracopt.perm.authz_policy may be unnecessary. After extracting a class from the trac.config module that provides a thin wrapper over ConfigParser, we can use that class instead of ConfigObj.

Attachments (0)

Change History (11)

comment:1 by Ryan J Ollos, 10 years ago

Milestone: next-dev-1.1.x1.1.5
Owner: set to Ryan J Ollos
Status: newassigned

Proposed changes in log:rjollos.git:t11982-remove-configobj:

  • More testing is needed. I plan to add more tests before committing.
  • One test is commented out. The issue is already captured in #11538. ConfigParser doesn't throw an exception due to duplicate sections or options.
  • Further modifications are possible when #11339 is implemented. I'd like to extract a class that can read and write a configuration file but has no coupling the ComponentManager or Option classes. The class with knowledge of ComponentManager and Option would utilize this extracted class to read and write the environment configuration. The extracted class could be utilized by the authz_policy module so that we have the capability to write authz files as well as read them.
Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Ryan J Ollos, 9 years ago

Revised changes in log:rjollos.git:t11982-remove-configobj.1. Tested so far on Mac OSX with Python 2.6 and Python 2.7.

comment:3 by Ryan J Ollos, 9 years ago

API Changes: modified (diff)
Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Tested also with Python 2.6 and 2.7 on Windows 7. Committed to trunk in [13993:13995]. More work on config module is forthcoming in #6551, and yet-to-be-created tickets.

I'll update the 1.1 documentation soon to remove ConfigObj from the optional dependencies.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:4 by Jun Omae, 9 years ago

I started to confirm [13393:13995]. At least, I think we should move the following try...except ImportError:... statements in trac/config.py to trac/util/compat.py like cleandoc() in trac-1.0.5.

 29 try:
 30     from collections import OrderedDict
 31 except ImportError:
 32     from trac.util.compat import OrderedDict

After moving that, we could simply replace with:

from trac.util.compat import OrderedDict

comment:5 by Ryan J Ollos, 9 years ago

Thanks, I modified the imports and removed some Python 2.7 compatibility code in the OrderedDict class in [13996].

Documentation edited in:

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:6 by Ryan J Ollos, 9 years ago

API Changes: modified (diff)
Release Notes: modified (diff)

comment:7 by Ryan J Ollos, 9 years ago

Minor additional change in [14036].

comment:8 by Ryan J Ollos, 9 years ago

Additional refactoring committed in [14130]: localizes utf-8 encoding / decoding to the UnicodeConfigParser class and removes ConfigurationStub.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:9 by Ryan J Ollos, 9 years ago

Additional refactoring is proposed in log:rjollos.git:t11982_refactoring_configuration. The aim is to avoid directly accessing UnicodeConfigParser._sections, not just because it is bad practice to access a protected attribute, but because the contents of _sections is utf-8 encoded and the content is decoded to unicode through the public interface of UnicodeConfigParser. All of the config module code works with unicode strings, except UnicodeConfigParser which serves as the boundary for encoding/decoding.

comment:10 by Ryan J Ollos, 9 years ago

Committed to trunk in [14138].

comment:11 by Ryan J Ollos, 8 years ago

These changes introduced a regression described in comment:8:ticket:12649.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.