[Zope] Re: STX and images

Danny William Adair danny@adair.net
Wed, 19 Sep 2001 02:10:46 -0400


<html>
<blockquote type=cite class=cite cite>Hmm, the code I posted was to work around the lack of underscore<br>
in Zope 2.3's version of StructuredText.DocumentWithImages.doc_href;<br>
in Zope 2.4, you shouldn't need my hack to fix 'doc_href'.&nbsp; OTOH,<br>
'doc_img' is still broken in Zope 2.4.<br><br>
The workaround should be to hack in 'doc_img' into your 'DWIClass',<br>
such that the patterns it passes to the base class' 'doc_img' include<br>
underscores.<br><br>
Tres.</blockquote><br>
Thanks Tres, I got it working!<br><br>
All I did was include the underscore in the regex, after the &quot;:img:&quot;.<br><br>
Original:<br>
------------------------------------------------------------------------------<br>
def doc_img( self, s,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr1 = re.compile('\&quot;([ _a-zA-Z0-9*.:/;,\-\n\~]+)\&quot;:img:([a-zA-Z0-9\-.:/;,\n\~]+)').search,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr2 = re.compile('\&quot;([ _a-zA-Z0-9*.:/;,\-\n\~]+)\&quot;:img:([a-zA-Z0-9\-.:/;,\n\~]+):([a-zA-Z0-9\-.:/;,\n\~]+)').search):<br>
------------------------------------------------------------------------------<br><br>
New:<br>
------------------------------------------------------------------------------<br>
def doc_img( self, s,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr1 = re.compile('\&quot;([ _a-zA-Z0-9*.:/;,\-\n\~]+)\&quot;:img:([_a-zA-Z0-9\-.:/;,\n\~]+)').search,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr2 = re.compile('\&quot;([ _a-zA-Z0-9*.:/;,\-\n\~]+)\&quot;:img:([_a-zA-Z0-9\-.:/;,\n\~]+):([a-zA-Z0-9\-.:/;,\n\~]+)').search):<br>
------------------------------------------------------------------------------<br><br>
So it was actually just two characters missing, hoho.<br>
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.<br><br>
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...<br><br>
Thanks for the help,<br>
Danny</html>