Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 51f7de0838007e2876221e819c82d833 > files > 577

sketch-0.6.13-2mdk.ppc.rpm

<html>
<head>
<title>Developer's Guide: Plugin Configuration</title>
</head>
<body bgcolor=white text=black link=blue vlink=navy alink=red>
<TABLE WIDTH="100%">
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
<TR>
<TD ALIGN="left"><A HREF="devguide-20.html">Plugins
</A></TD>
<TD ALIGN="center"><A HREF="devguide-20.html">Plugins
</A></TD>
<TD ALIGN="right"><A HREF="devguide-22.html">Import Filters
</A></TD>
</TR>
</TABLE>
<HR NOSHADE>
<H2><FONT face="Helvetica,Arial"><A NAME="N1"></A>Plugin Configuration</font></H2>

<P>On startup, Sketch searches for plugins on the <EM>plugin path</EM>. Every
Python source file found is scanned for configuration information.
Later, when the the plugin is needed it is imported.</P>
<P>The plugin path is a list of directories stored in
<CODE>Sketch.config.plugin_path</CODE>. The directory names should be absolute
pathnames. Sketch uses a notation borrowed from the kpathsea library
(which is used by many TeX programs to search files):
<UL>
<LI>If a directory name ends in a slash ('/') search in that
directory and in the directories immediately contained in it.
</LI>
<LI>If a directory name ends with two slashes ('//') search in
that directory and recursively in all subdirectories.
</LI>
<LI>Else, search only in that directory</LI>
</UL>
</P>

<P>The configuration information is a series of Python statements
(assignments), each on its own line, between the lines '<CODE>###Sketch
Config</CODE>' and `<CODE>###End</CODE>'.</P>
<P>One of the assignments must be to a variable named `<CODE>type</CODE>'. This
specifies the type of the plugin (import filter, plugin object, etc.).</P>
<P>Another variable that may be used in the future, is `<CODE>version</CODE>' which
will be used to specify the version of the plugin-config conventions
used (not the version of the plugin itself).</P>
<P>Other variable names are type dependent.</P>
<P>Each of the lines may be commented out.</P>
<P>Example:
<table width="100%" cellpadding="10"><tr><td bgcolor="#FFFFD0">
<PRE>
###Sketch Config
#type = Import
#class_name = 'SKLoader'
#rx_magic = '^##Sketch 1 *(?P&lt;minor&gt;[0-9]+)'
#tk_file_type = ('Sketch Document', '.sk')
format_name = 'SK-1'
###End
</PRE>
</td></tr></table>
</P>
<P>Sketch uses this method--instead of importing every plugin module
and requiring that they register themselves with the plugin
manager--to avoid loading unnecessary modules.</P>
<P>Implementation Note: currently Sketch reads the lines between
`###Sketch Config' and `###End' into a single string (after removing the
initial `#'s if present) and exec's it with a globals dictionary
containing the predefined plugin types and an empty locals dictionary
which receives all the variables. A consequence of this approach is that
it is currently possible to use arbitrary Python statements and not just
assignments. Don't rely on this, it could be changed in the future.</P>


<HR NOSHADE>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="left"><A HREF="devguide-20.html">Plugins
</A></TD>
<TD ALIGN="center"><A HREF="devguide-20.html">Plugins
</A></TD>
<TD ALIGN="right"><A HREF="devguide-22.html">Import Filters
</A></TD>
</TR>
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
</TABLE>
</body>
</html>