Opened 21 years ago
Closed 21 years ago
#198 closed defect (fixed)
Dependency on py-xml unnecessary
Reported by: | daniel | Owned by: | Jonas Borgström |
---|---|---|---|
Priority: | normal | Milestone: | 0.6.1 |
Component: | general | Version: | 0.6 |
Severity: | trivial | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
The only function used from pyxml is saxutils.escape, which is a trivial function.
I believe we can duplicate its behavior in util.py without committing karmic suicide. :)
Attachments (0)
Change History (5)
comment:1 by , 21 years ago
comment:2 by , 21 years ago
On Suse 9.0, python xml is not included in the default python package. I had to install python-xml in order to get Trac working properly with xml.sax. I don't know if this is typical or not (maybe other linux distro's include the xml stuff in the default python package?)
comment:3 by , 21 years ago
I checked out branches/0.6-stable (Mar/28/2004 12:45am EST). Here is the 'svn diff' output for fixing trac/util.py to no longer need python-xml.
Index: trac/util.py =================================================================== --- trac/util.py (revision 321) +++ trac/util.py (working copy) @@ -23,7 +23,6 @@ import time import StringIO from types import * -from xml.sax import saxutils def svn_date_to_string(date, pool): from svn import util @@ -62,13 +61,22 @@ def escape(text, param={'"':'"'}): """Escapes &, <, > and \"""" - if not text: - return '' - elif type(text) is StringType: - return saxutils.escape(text, param) + + newText = '' + + if type(text) is StringType: + newText = text \ + .replace(">", ">") \ + .replace("<", "<") \ + .replace("&", "&") + if param: + for k, v in param.items(): + newText = newText.replace(k, v) else: - return text + newText = text + return newText + def get_first_line(text, maxlen): """ returns the first line of text. If the line is longer then
comment:4 by , 21 years ago
Oh, one other comment. If the diff attached to Ticket #163 has been applied, be sure to remove the line in setup.cfg that references python-xml.
comment:5 by , 21 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
A modified version of the patch is applied to both trunk and 0.6-stable.
The patch above does the replacing in the wrong order. You have to replace & before anything else.
Thanks!
Hmm, is this really true?
I thought xml.sax was part of Python?
Is it really not included in the standard distribution on all platforms?
On Suse, pyxml seems to be the 4thought XML stuff, not the xml.sax stuff we normally find in the standard python lib.