[Zope] Using win32com from external method

Micheál Healy michael.healy@engitech.ie
Tue, 4 Mar 2003 14:12:54 -0000


This is a multi-part message in MIME format.

------=_NextPart_000_0022_01C2E258.261B06A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by lxgate1.engitech.ie id OAA08213

Hi,

I want to use win32com.client in a python script which I wish to access a=
s
an External Method.  When I run the script outside of Zope, it works fine.
Then I add a method declaration, and try to add the same script as an
extenal method and I get the following error:

Error Type: ImportError
Error Value: No module named pythoncom

The import statements look like this:

import pythoncom
import win32com.client

When I run outside Zope, I don=92t actually need to import pythoncom.


I downloaded COMObject-1.0.1-nonbin.tgz and took a look at what I may nee=
d
to do to get it working (figured that if I could get this to work, my
problem would be solved). The following is from the README.txt:

=93Probably the easiest way to get the win32 extensions working with Zope=
 is
to use your own Python, rather than the Python that comes with Zope.=94

If this is what I have to do, then how?  I=92ve looked for anything on th=
is,
but it=92s not the easiest thing to search for.  If I do this, will I sti=
ll be
able to access the things I have added in the \Zope\lib\python\Products,
such as TinyTable, Calendar and ZGDChart?

Thanks for any help,

Miche=E1l


Miche=E1l Healy
Engitech Ltd.
01 6204 516


------=_NextPart_000_0022_01C2E258.261B06A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 9">
<meta name=3DOriginator content=3D"Microsoft Word 9">
<link rel=3DFile-List href=3D"cid:filelist.xml@01C2E258.23D8B7C0">
<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>75</w:Zoom>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:HyphenationZone>14</w:HyphenationZone>
  <w:EnvelopeVis/>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:16792199 0 0 0 65791 0;}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:Tahoma;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	mso-ansi-language:EN-GB;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
	{margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:Tahoma;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	mso-ansi-language:EN-GB;}
span.EmailStyle16
	{mso-style-type:personal-compose;
	mso-ansi-font-size:10.0pt;
	mso-ascii-font-family:Arial;
	mso-hansi-font-family:Arial;
	mso-bidi-font-family:Arial;
	color:black;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:70.85pt 2.0cm 2.0cm 2.0cm;
	mso-header-margin:35.4pt;
	mso-footer-margin:35.4pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
</head>

<body lang=3DIT style=3D'tab-interval:35.4pt'>

<div class=3DSection1>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>Hi,<o:p></o:p></span></span></font></=
span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>I want to use win32com.client in a =
python
script which I wish to access as an External Method.<span =
style=3D"mso-spacerun:
yes">&nbsp; </span>When I run the script outside of Zope, it works =
fine.<span
style=3D"mso-spacerun: yes">&nbsp; </span>Then I add a method =
declaration, and try
to add the same script as an extenal method and I get the following =
error:<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><strong><b><font size=3D2 color=3Dblack =
face=3DTahoma><span
lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-family:Tahoma;color:black'><span
style=3D'mso-bidi-font-size:12.0pt'>Error Type: =
ImportError</span></span></font></b></strong><font
color=3Dblack><span lang=3DEN-GB style=3D'color:black'><br>
<strong><b>Error Value: No module named =
pythoncom</b></strong></span></font><span
class=3DEmailStyle16><font color=3Dblack face=3DArial><span lang=3DEN-GB
style=3D'font-family:Arial'><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>The import statements look like =
this:<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>import =
pythoncom<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>import =
win32com.client<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>When I run outside Zope, I =
don&#8217;t actually
need to import pythoncom.<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>I downloaded =
COMObject-1.0.1-nonbin.tgz and
took a look at what I may need to do to get it working (figured that if =
I could
get this to work, my problem would be solved). The following is from the
README.txt:<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>&#8220;Probably the easiest way to =
get the win32
extensions working with Zope is to use your own Python, rather than the =
Python
that comes with Zope.&#8221;<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>If this is what I have to do, then =
how?<span
style=3D"mso-spacerun: yes">&nbsp; </span>I&#8217;ve looked for anything =
on this, but
it&#8217;s not the easiest thing to search for.<span =
style=3D"mso-spacerun: yes">&nbsp;
</span>If I do this, will I still be able to access the things I have =
added in
the \Zope\lib\python\Products, such as TinyTable, Calendar and =
ZGDChart?<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>Thanks for any =
help,<o:p></o:p></span></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Arial'><span
style=3D'mso-bidi-font-size:12.0pt'>Miche=E1l<o:p></o:p></span></span></f=
ont></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoNormal><span class=3DEmailStyle16><font size=3D2 =
color=3Dblack
face=3DArial><span lang=3DEN-GB =
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;
font-family:Arial'><![if =
!supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></font></span></p>

<p class=3DMsoAutoSig><!--[if supportFields]><font size=3D3 =
color=3Dblack=20
face=3D"Times New Roman"><span lang=3DEN-GB =
style=3D'font-size:12.0pt;font-family:
"Times New Roman";color:black'><span =
style=3D'mso-element:field-begin'></span><span=20
style=3D"mso-spacerun: yes">&nbsp;</span>AUTOTEXTLIST \s &quot;E-mail=20
Signature&quot; <span =
style=3D'mso-element:field-separator'></span></span></font><![endif]--><f=
ont
color=3Dblack face=3DArial><span lang=3DEN-GB =
style=3D'font-family:Arial;color:black'>Miche=E1l
Healy</span></font><font color=3Dblack face=3DArial><span lang=3DEN-GB
style=3D'font-family:Arial;color:black;mso-color-alt:windowtext'><o:p></o=
:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 color=3Dblack face=3DArial><span =
lang=3DEN-GB
style=3D'font-size:10.0pt;font-family:Arial;color:black'><span =
style=3D'mso-bidi-font-size:
12.0pt'>Engitech Ltd.</span></span></font><font color=3Dblack =
face=3DArial><span
lang=3DEN-GB =
style=3D'font-family:Arial;color:black;mso-color-alt:windowtext'><o:p></o=
:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 color=3Dblack face=3DArial><span =
lang=3DEN-GB
style=3D'font-size:10.0pt;font-family:Arial;color:black'><span =
style=3D'mso-bidi-font-size:
12.0pt'>01 6204 516</span></span></font><font color=3Dblack =
face=3DArial><span
lang=3DEN-GB =
style=3D'font-family:Arial;color:black;mso-color-alt:windowtext'><o:p></o=
:p></span></font></p>

<p class=3DMsoNormal><!--[if supportFields]><font size=3D3 color=3Dblack =

face=3D"Times New Roman"><span lang=3DEN-GB =
style=3D'font-size:12.0pt;font-family:
"Times New Roman";color:black'><span =
style=3D'mso-element:field-end'></span></span></font><![endif]--><font
size=3D3 color=3Dblack face=3D"Times New Roman"><span lang=3DEN-GB =
style=3D'font-size:
12.0pt;font-family:"Times New Roman";color:black'><![if =
!supportEmptyParas]>&nbsp;<![endif]></span></font><font
size=3D3 color=3Dblack face=3D"Times New Roman"><span lang=3DEN-GB =
style=3D'font-size:
12.0pt;font-family:"Times New =
Roman";color:black;mso-color-alt:windowtext'><o:p></o:p></span></font></p=
>

</div>

</body>

</html>

------=_NextPart_000_0022_01C2E258.261B06A0--