[Zope] Re: STX and images

Danny William Adair danny@adair.net
Thu, 23 Aug 2001 11:55:45 +1200


>Hmm, the code I posted was to work around the lack of underscore
>in Zope 2.3's version of StructuredText.DocumentWithImages.doc_href;
>in Zope 2.4, you shouldn't need my hack to fix 'doc_href'.  OTOH,
>'doc_img' is still broken in Zope 2.4.
>
>The workaround should be to hack in 'doc_img' into your 'DWIClass',
>such that the patterns it passes to the base class' 'doc_img' include
>underscores.
>
>Tres.

Thanks Tres, I got it working!

All I did was include the underscore in the regex, after the ":img:".

Original:
------------------------------------------------------------------------------
def doc_img( self, s,
              expr1 = re.compile('\"([ 
_a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\-.:/;,\n\~]+)').search,
              expr2 = re.compile('\"([ 
_a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\-.:/;,\n\~]+):([a-zA-Z0-9\-.:/;,\n\~]+)').search):
------------------------------------------------------------------------------

New:
------------------------------------------------------------------------------
def doc_img( self, s,
              expr1 = re.compile('\"([ 
_a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([_a-zA-Z0-9\-.:/;,\n\~]+)').search,
              expr2 = re.compile('\"([ 
_a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([_a-zA-Z0-9\-.:/;,\n\~]+):([a-zA-Z0-9\-.:/;,\n\~]+)').search):
------------------------------------------------------------------------------

So it was actually just two characters missing, hoho.
After rewriting this using the easier to read _ABS_AND_RELATIVE_URL 
notation of DocumentClass.py I will post the external method for others to use.

I have the feeling that when DocumentClass.py (CVS 2 weeks) was updated, 
DocumentWithImages.py wasn't (CVS 2 months)... so copy goes to Andreas...

Thanks for the help,
Danny