[Zope-Checkins] Re: CVS: Zope2 - HTTPResponse.py:1.46

Chris McDonough chrism@digicool.com
Tue, 24 Apr 2001 12:03:19 -0400


Do you mean to be checking this stuff into the trunk?

----- Original Message -----
From: "Andreas Jung" <andreas@dhcp165.digicool.com>
To: <zope-checkins@zope.org>
Sent: Tuesday, April 24, 2001 11:59 AM
Subject: [Zope-Checkins] CVS: Zope2 - HTTPResponse.py:1.46


> Update of /cvs-repository/Zope2/lib/python/ZPublisher
> In directory yetix:/work/sandboxes/Zope2/lib/python/ZPublisher
>
> Modified Files:
> HTTPResponse.py
> Log Message:
> regex free
>
>
>
> --- Updated File HTTPResponse.py in package Zope2 --
> --- HTTPResponse.py 2001/04/07 16:07:09 1.45
> +++ HTTPResponse.py 2001/04/24 15:59:49 1.46
> @@ -87,7 +87,7 @@
>  $Id$'''
>  __version__='$Revision$'[11:-2]
>
> -import string, types, sys, regex, re
> +import string, types, sys,  re
>  from string import find, rfind, lower, upper, strip, split, join,
translate
>  from types import StringType, InstanceType, LongType
>  from BaseResponse import BaseResponse
> @@ -271,7 +271,7 @@
>      __setitem__=setHeader
>
>      def setBody(self, body, title='', is_error=0,
> -                bogus_str_search=regex.compile(" [a-fA-F0-9]+>$").search,
> +                bogus_str_search=re.compile(" [a-fA-F0-9]+>$").search,
>                  latin1_alias_match=re.compile(
>                  r'text/html(\s*;\s*charset=((latin)|(latin[-_]?1)|'
>                  r'(cp1252)|(cp819)|(csISOLatin1)|(IBM819)|(iso-ir-100)|'
> @@ -304,7 +304,7 @@
>          body=str(body)
>          l=len(body)
>          if ((l < 200) and body[:1]=='<' and find(body,'>')==l-1 and
> -            bogus_str_search(body) > 0):
> +            bogus_str_search(body) is not None):
>              self.notFoundError(body[1:-1])
>          else:
>              if(title):
> @@ -343,8 +343,7 @@
>          self.base=base
>
>      def insertBase(self,
> -                   base_re_search=regex.compile('\(<base[\0- ]+[^>]+>\)',
> -                                                regex.casefold).search
> +                   base_re_search=re.compile('(<base.*?>)',re.I).search
>                     ):
>
>          # Only insert a base tag if content appears to be html.
> @@ -359,7 +358,7 @@
>                  if match is not None:
>                      index=match.start(0) + len(match.group(0))
>                      ibase=base_re_search(body)
> -                    if ibase < 0:
> +                    if ibase is None:
>                          self.body=('%s\n<base href="%s" />\n%s' %
>                                     (body[:index], self.base,
body[index:]))
>                          self.setHeader('content-length', len(self.body))
> @@ -560,7 +559,7 @@
>
>      def badRequestError(self,name):
>          self.setStatus(400)
> -        if regex.match('^[A-Z_0-9]+$',name) >= 0:
> +        if re.match('^[A-Z_0-9]+$',name):
>              raise 'InternalError', self._error_html(
>                  "Internal Error",
>                  "Sorry, an internal error occurred in this resource.")
> @@ -589,13 +588,7 @@
>          raise 'Unauthorized', m
>
>      def exception(self, fatal=0, info=None,
> -                  absuri_match=regex.compile(
> -                      "^"
> -                      "\(/\|\([a-zA-Z0-9+.-]+:\)\)"
> -                      "[^\000- \"\\#<>]*"
> -                      "\\(#[^\000- \"\\#<>]*\\)?"
> -                      "$"
> -                      ).match,
> +                  absuri_match=re.compile(r'\w+://[\w\.]+').match,
>                    tag_search=re.compile('[a-zA-Z]>').search,
>                    abort=1
>                    ):
> @@ -628,7 +621,7 @@
>          stb=None
>          self.setStatus(t)
>          if self.status >= 300 and self.status < 400:
> -            if type(v) == types.StringType and absuri_match(v) >= 0:
> +            if type(v) == types.StringType and absuri_match(v) is not
None:
>                  if self.status==300: self.setStatus(302)
>                  self.setHeader('location', v)
>                  tb=None
> @@ -636,7 +629,7 @@
>              else:
>                  try:
>                      l,b=v
> -                    if type(l) == types.StringType and absuri_match(l) >=
0:
> +                    if type(l) == types.StringType and absuri_match(l) is
not None:
>                          if self.status==300: self.setStatus(302)
>                          self.setHeader('location', l)
>                          self.setBody(b)
> @@ -704,7 +697,7 @@
>          return cookie_list
>
>      def __str__(self,
> -
html_search=regex.compile('<html>',regex.casefold).search,
> +                html_search=re.compile('<html>',re.I).search,
>                  ):
>          if self._wrote: return ''       # Streaming output was used.
>
> @@ -770,3 +763,4 @@
>              self.stdout.flush()
>
>          self.stdout.write(data)
> +
>
>
> _______________________________________________
> Zope-Checkins maillist  -  Zope-Checkins@zope.org
> http://lists.zope.org/mailman/listinfo/zope-checkins
>