Expose Python library to PerlScript using WSC 
Author Message
 Expose Python library to PerlScript using WSC

Hi,

I would like to use the ReportLab toolkit ( http://www.*-*-*.com/ )
to produce PDF documents using PerlScript (via WSH). However, this
library is written for Python. I would like to use WSC (and
ActivePython) to expose the ReportLab library to Perl so that we can
take advantage of its features. Sample code follows :

<?xml version="1.0"?>
<component>
        <?component error="true" debug="true"?>

        <registration
                description="ColourTest"
                progid="ColourTest.WSC"
                version="1.00"
                classid="{8991a7a1-25e6-4d7b-9a96-45797114fc3d}"
        >
        </registration>

        <public>
                <method name="Canvas"/>
                <method name="GetAllNamedColors"/>
        </public>

        <script language="Python">
                <![CDATA[
import reportlab.pdfgen.canvas
from reportlab.lib import colors
from reportlab.lib.units import inch

def Canvas( WScript, Filename ):
        WScript.Echo( "Filename : '" + Filename + "'" )
        Value = reportlab.pdfgen.canvas.Canvas( Filename )
        Value.setFont('Times-BoldItalic', 20)
        return Value

def GetAllNamedColors():
        return reportlab.lib.colors.getAllNamedColors()
        ]]>
        </script>
</component>

The problem is, when I use the 'Canvas' method, an undefined value is
returned to my PerlScript. But in the above function, the setFont
function works. Can anybody tell me why this is so?



Thu, 13 Jan 2005 21:57:10 GMT  
 Expose Python library to PerlScript using WSC
Looks like ColourTest.Canvas method creates
reportlab.pdfgen.canvas.Canvas object and it is scoped to go out of
existence.



<snip>

Quote:
>The problem is, when I use the 'Canvas' method, an undefined value is
>returned to my PerlScript. But in the above function, the setFont
>function works. Can anybody tell me why this is so?



Thu, 13 Jan 2005 23:32:21 GMT  
 Expose Python library to PerlScript using WSC

Quote:
> Looks like ColourTest.Canvas method creates
> reportlab.pdfgen.canvas.Canvas object and it is scoped to go out of
> existence.

Being a newbie to Python, how would I keep the object within scope.
Normally under C++ I'd dynamically allocate the object and return a
pointer. Under Perl, you can just return the object without worrying
about scope. How is it done in Python?

Regards,

Camel



Fri, 14 Jan 2005 09:46:31 GMT  
 Expose Python library to PerlScript using WSC
#!perl
#script to demo variable scope in the same perl file
#
use strict;
$something = 'nothing';
{my $something = &GimmeSomething ();}
print "When something is $something\n";
#
#When something is nothing

sub GimmeSomething {
  return 'something';

Quote:
}



<snip>

Quote:
>Under Perl, you can just return the object without worrying
>about scope.

<snip>


Fri, 14 Jan 2005 11:12:55 GMT  
 Expose Python library to PerlScript using WSC

Quote:

> Hi,

> I would like to use the ReportLab toolkit (http://www.reportlab.com)
> to produce PDF documents using PerlScript (via WSH). However, this
> library is written for Python. I would like to use WSC (and
> ActivePython) to expose the ReportLab library to Perl so that we can
> take advantage of its features.

The best place to ask for help on this would be python newsgroup
(comp.lang.python).

Branimir



Fri, 14 Jan 2005 23:01:48 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Determine all libraries that expose a COM interface..

2. HOW TO generate a library from a WSC ?

3. Using Python with WSH

4. Has Anyone used PerlScript from ActiveState on an Win-95

5. Using WSC and DCOM

6. Using WSC files from ASP (VBScript)

7. Using WScrip.Echo in a WSC file....?

8. Using WSC files from ASP (VBScript)

9. Interfacing with Access object using WSC written in JScript

10. Using WScript object in WSC components

11. Using Wscript Objects in WSC

12. Using an ActiveX control within MSG.WSC

 

 
Powered by phpBB® Forum Software