<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ghattu&#039;s Technology Blog &#187; jython</title>
	<atom:link href="http://ghattus.com/category/jython/feed/" rel="self" type="application/rss+xml" />
	<link>http://ghattus.com</link>
	<description>A blog about technology that I work on in my day to day job</description>
	<lastBuildDate>Thu, 03 Dec 2009 00:56:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Old WLST tools</title>
		<link>http://ghattus.com/2009/12/02/old-wlst-tools/</link>
		<comments>http://ghattus.com/2009/12/02/old-wlst-tools/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 00:56:54 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[Application Server]]></category>
		<category><![CDATA[WebLogic]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[wlst]]></category>

		<guid isPermaLink="false">http://ghattus.com/?p=165</guid>
		<description><![CDATA[As you might know after the acquisition of BEA Systems by Oracle, Dev2Dev site has been discontinued. Unfortunately I don&#8217;t see a replacement for that, not only we lost some rich information, but a number of good tools. In that context, in the last few months I had inquiries from some users asking where they could find the original [...]]]></description>
			<content:encoded><![CDATA[<p>As you might know after the acquisition of BEA Systems by Oracle, Dev2Dev site has been discontinued. Unfortunately I don&#8217;t see a replacement for that, not only we lost some rich information, but a number of good tools.<span id="more-165"></span></p>
<p>In that context, in the last few months I had inquiries from some users asking where they could find the original WLST that works with WebLogic 8.1 and 7.0, also WLST Script Generator and Console extension that work with WebLogic 9.x.</p>
<p>Now you can get these from the new google code project <a href="http://wlst-archives.googlecode.com/">wlst-modules</a>. WLST Script Generator 9.x can be downloaded from <a href="http://wlst-archives.googlecode.com/files/wlstScriptGenerator_91.zip">here</a>. The zip contains a ReadMe.html that should walk you through the configurations steps. And for those unfortunate souls who are still using WebLogic 7.0 and 8.1, WLST jar can be downloaded from <a href="http://wlst-archives.googlecode.com/files/wlst.jar">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2009/12/02/old-wlst-tools/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Interview with Jython Lead</title>
		<link>http://ghattus.com/2009/10/21/interview-with-jython-lead/</link>
		<comments>http://ghattus.com/2009/10/21/interview-with-jython-lead/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 00:45:13 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[WebLogic]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>

		<guid isPermaLink="false">http://ghattus.com/?p=151</guid>
		<description><![CDATA[Just came across this excellent interview with Frank Wierzbicki, who now leads the Jython Development. Interview can be found here]]></description>
			<content:encoded><![CDATA[<p>Just came across this excellent interview with Frank Wierzbicki, who now leads the Jython Development.</p>
<p>Interview can be found <a href="http://www.thebitsource.com/2009/09/26/jython-programming-language-frank-wierzbicki/">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2009/10/21/interview-with-jython-lead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No WLST cachedir with python.cachedir.skip</title>
		<link>http://ghattus.com/2009/09/11/no-wlst-cachedir-with-python-cachedir-skip/</link>
		<comments>http://ghattus.com/2009/09/11/no-wlst-cachedir-with-python-cachedir-skip/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 16:11:21 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[WebLogic]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[weblogic server]]></category>
		<category><![CDATA[wlst]]></category>
		<category><![CDATA[cachedir]]></category>
		<category><![CDATA[WebLogic 11g]]></category>

		<guid isPermaLink="false">http://ghattus.com/?p=111</guid>
		<description><![CDATA[In one of my previous post I have talked about python.cachedir and how it may cause some errors during WLST/Jython initialization. With WebLogic 11g Oracle has upgraded the Jython Version from 2.1 to 2.2 (see my post here), which opens up yet another way of getting rid of these errors. In fact you can get [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my previous <a href="http://ghattus.com/2009/08/how-are-python-cachedir-and-the-error-sys-package-mgr-cant-create-package-cache-dir-are-related.html">post</a> I have talked about python.cachedir and how it may cause some errors during WLST/Jython initialization.<br />
With WebLogic 11g <a href="http://www.oracle.com">Oracle </a>has upgraded the Jython Version from 2.1 to 2.2 (see my post <a href="http://ghattus.com/2009/08/jython-2-2-in-weblogic-11g.html">here</a>), which opens up yet another way of getting rid of these errors. In fact you can get rid of the cachedir entirely by starting WLST with <strong>-Dpython.cachedir.skip=true</strong>, this will instruct Jython not to create the CacheDir.<br />
I haven&#8217;t done extensive testing with this option but so far I haven&#8217;t seen any issues by not creating this cachedir.</p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2009/09/11/no-wlst-cachedir-with-python-cachedir-skip/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Jython 2.2 in WebLogic 11g</title>
		<link>http://ghattus.com/2009/08/21/jython-2-2-in-weblogic-11g/</link>
		<comments>http://ghattus.com/2009/08/21/jython-2-2-in-weblogic-11g/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 12:27:24 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[WebLogic]]></category>
		<category><![CDATA[fusion middleware]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wlst]]></category>

		<guid isPermaLink="false">http://ghattus.com/?p=127</guid>
		<description><![CDATA[I just started playing around with WebLogic Server 11g and realised that Oracle has upgraded Jython from 2.1 to 2.2, very nice! For a brief description on what&#8217;s new with Jython 2.2 see my old post here. E:\WebLogic11g\Oracle\Middleware\wlserver_10.3\common\bin&#62;java org.python.util.jython Jython 2.2.1 on java1.6.0_05 &#62;&#62;&#62;]]></description>
			<content:encoded><![CDATA[<p>I just started playing around with WebLogic Server 11g and realised that Oracle has upgraded Jython from 2.1 to 2.2, very nice!</p>
<p><span id="more-127"></span></p>
<p>For a brief description on what&#8217;s new with Jython 2.2 see my old post <a href="http://ghattus.com/2007/08/jython-2-2-is-finally-here.html">here</a>.</p>
<blockquote><p>E:\WebLogic11g\Oracle\Middleware\wlserver_10.3\common\bin&gt;java org.python.util.jython<br />
<strong>Jython 2.2.1 on java1.6.0_05<br />
</strong>&gt;&gt;&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2009/08/21/jython-2-2-in-weblogic-11g/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How are python.cachedir and the error &quot;*sys-package-mgr*: can&#039;t create package cache dir&quot; are related</title>
		<link>http://ghattus.com/2009/08/04/how-are-python-cachedir-and-the-error-sys-package-mgr-cant-create-package-cache-dir-are-related/</link>
		<comments>http://ghattus.com/2009/08/04/how-are-python-cachedir-and-the-error-sys-package-mgr-cant-create-package-cache-dir-are-related/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 10:50:02 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[WebLogic]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[jython syntax]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wlst]]></category>
		<category><![CDATA[/var/tmp]]></category>
		<category><![CDATA[cachedir]]></category>
		<category><![CDATA[ImportError]]></category>
		<category><![CDATA[sys-package-mgr]]></category>

		<guid isPermaLink="false">http://ghattus.com/?p=57</guid>
		<description><![CDATA[Resolving "*sys-package-mgr*: can't create package cache dir" errors with WLST]]></description>
			<content:encoded><![CDATA[<p>While starting <a href="http://edocs.bea.com/wls/docs91/config_scripting/index.html">WLST </a>or for that matter <a href="http://www.jython.org">Jython</a>, you might have seen this annoying error message,</p>
<blockquote><p>*sys-package-mgr*: can&#8217;t create package cache dir, &#8216;/tmp/cachedir/packages&#8217;<br />
Traceback (innermost last):<br />
File &#8220;&lt;iostream&gt;&#8221;, line 12, in ?<br />
ImportError: no module named java</p></blockquote>
<p><span id="more-57"></span></p>
<p>When Jython initializes it scans all the jar files it can find at startup to build the package and class structure available to the JVM. This information is written to files in a directory named &#8216;cachedir&#8217;, WLST chooses your &#8216;java.io.tmpdir&#8217; to store these files. There is a problem with this approach especially on Unix machines.</p>
<p><strong>Problem:</strong></p>
<p>Most Unix machines are shared across a number of users. Say &#8220;user1&#8243; first logs into the machine and fired up &#8216;java weblogic.WLST&#8217;, Jython will create the &#8216;cachedir&#8217; under <strong>&#8216;/var/tmp/&#8217;</strong> and this directory will be owned by &#8216;user1&#8242;. This user will have no problems using WLST. Now &#8216;user2&#8242; logs in and fires up WLST, this process will try to write to the same directory, <strong>&#8216;/var/tmp/cachedir&#8217;</strong> which is now owned by &#8216;user1&#8242; and hence fails with the above error message.</p>
<p><strong>Solution:</strong></p>
<p>There is a pretty simple and straight forward solution to this problem. Jython supports a System property (<strong>python.cachedir</strong>) that you can set which will determine the directory where this &#8216;cachedir&#8217; is created. So in our case to start WLST you will use,</p>
<blockquote><p>java -Dpython.cachedir=/home/user1 weblogic.WLST</p></blockquote>
<p>This will create the cachedir under /home/user1, and this way all users can have their own cachedir&#8217;s without running into each other. For a more elegant solution you can create a simple unix script that wraps the call to WLST and adding the right cachedir location per user. Sample is shown below,</p>
<blockquote><p>#!/bin/sh</p>
<p># Setup classpath, probably execute setDomainEnv.sh</p>
<p>java -Dpython.cachedir=~ weblogic.WLST</p></blockquote>
<p>As long as the<strong> &#8216;~&#8217;</strong> resolves properly to the home directory for the user executing WLST you will never have to worry about this &#8216;cachedir&#8217; related error messages.. <img src='http://ghattus.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2009/08/04/how-are-python-cachedir-and-the-error-sys-package-mgr-cant-create-package-cache-dir-are-related/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Default protocol in WebLogic and why is it important</title>
		<link>http://ghattus.com/2009/07/26/default-protocol-in-weblogic-and-why-is-it-important/</link>
		<comments>http://ghattus.com/2009/07/26/default-protocol-in-weblogic-and-why-is-it-important/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 21:17:12 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[WebLogic]]></category>
		<category><![CDATA[channel]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[weblogic server]]></category>
		<category><![CDATA[wlst]]></category>
		<category><![CDATA[protocol]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[t3]]></category>
		<category><![CDATA[t3s]]></category>

		<guid isPermaLink="false">http://ghattus.com/?p=55</guid>
		<description><![CDATA[It is a good practice to set the Default Protocol in WebLogic]]></description>
			<content:encoded><![CDATA[<p>If your WebLogic Server makes outbound connections to other systems it is wise to know what a DefaultProtocol is. Generally, when you create a WebLogic domain and haven&#8217;t configured SSL you will not have to do anything.<span id="more-55"></span></p>
<p>But once SSL is configured and you have dis-abled the non-ssl port, you should make sure that the DefaultProtocol your WebLogic Server uses is SSL (either t3s, https or iiops). If you haven&#8217;t done this, your WebLogic Server will try to use &#8220;t3&#8243; (default) for any outbound connections and since the ListenPort is disabled it will fail.</p>
<p>Here&#8217;s a simple wlst script to change the default protocol to t3s for all the servers in the domain.</p>
<blockquote><p># After connecting to the Admin Server</p>
<p>edit()</p>
<p>startEdit()</p>
<p>servers = cmo.getServers()</p>
<p>for i in servers:</p>
<p>i.setDefaultProtocol(&#8220;t3s&#8221;)</p>
<p>save()</p>
<p>activate()</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2009/07/26/default-protocol-in-weblogic-and-why-is-it-important/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IDE for WLST</title>
		<link>http://ghattus.com/2008/10/22/ide-for-wlst/</link>
		<comments>http://ghattus.com/2008/10/22/ide-for-wlst/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 02:03:00 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[JyDT]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[wlst]]></category>

		<guid isPermaLink="false">http://ghattus.com/2008/10/ide-for-wlst/</guid>
		<description><![CDATA[I have been asked this question many times and recently here, &#8220;What IDE should I use for writing WLST/Jython Scripts?&#8221; Initially I used PyWin, it was great! After I started using Eclipse as my Java IDE I moved to JyDT. JyDT has all the features I needed, integrates nicely with Eclipse, provides Syntax higlighting and [...]]]></description>
			<content:encoded><![CDATA[<p>I have been asked this question many times and recently <a href="https://www.blogger.com/comment.g?blogID=9892791&amp;postID=17367144129766315">here</a>, &#8220;What IDE should I use for writing WLST/Jython Scripts?&#8221; Initially I used <a href="http://pydev.sourceforge.net/">PyWin</a>, it was great! After I started using Eclipse as my Java IDE I moved to <a href="http://www.redrobinsoftware.net/jydt/">JyDT</a>. JyDT has all the features I needed, integrates nicely with Eclipse, provides Syntax higlighting and much more. I recommend JyDT if you are just starting of with Jython.</p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2008/10/22/ide-for-wlst/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jython 2.2 is finally here!</title>
		<link>http://ghattus.com/2007/08/23/jython-2-2-is-finally-here/</link>
		<comments>http://ghattus.com/2007/08/23/jython-2-2-is-finally-here/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 02:13:00 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[jython]]></category>

		<guid isPermaLink="false">http://ghattus.com/2007/08/jython-2-2-is-finally-here/</guid>
		<description><![CDATA[The first major production release of Jython after almost 6 years is finally here. Jython 2.2 implements Python 2.2 and also includes a number of features from Python 2.3. Few major features that I like include: New-style classes and their instances are Java serializable Java collections integration New and Improved socket module Support for JDK1.5 [...]]]></description>
			<content:encoded><![CDATA[<p>The first major production release of Jython after almost 6 years is finally here. Jython 2.2 implements Python 2.2 and also includes a number of features from Python 2.3.  Few major features that I like include:
<ul>
<li>New-style classes and their instances are Java serializable</li>
<p>
<li>Java collections integration</li>
<p>
<li>New and Improved socket module</li>
<p>
<li>Support for JDK1.5 and 1.6</li>
<p>
<li>telnetlib from CPython</li>
<p>
<li>Lots of bug fixes</li>
<p></ul>
<p>The complete changelog is posted at http://www.jython.org/NEWS.<br />I hope BEA will consider bundling Jython 2.2 in its next major release.</p>
<p>_uacct = &#8220;UA-2684269-2&#8243;;<br />urchinTracker();</p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2007/08/23/jython-2-2-is-finally-here/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jython is just too useful</title>
		<link>http://ghattus.com/2006/02/15/jython-is-just-too-useful/</link>
		<comments>http://ghattus.com/2006/02/15/jython-is-just-too-useful/#comments</comments>
		<pubDate>Thu, 16 Feb 2006 03:09:00 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[jython]]></category>

		<guid isPermaLink="false">http://ghattus.com/2006/02/jython-is-just-too-useful/</guid>
		<description><![CDATA[Recently I had to do this repeatedly while working on a project. 1) Revert files with extension .foo that are checked out from source control under a base directory structure.2) Sync to the latest copy of these files. 3) Make a copy of these files with extension .foo in a directory that are in different [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had to do this repeatedly while working on a project. <br />1) Revert files with extension .foo that are checked out from source control under a base directory structure.<br />2) Sync to the latest copy of these files. <br />3) Make a copy of these files with extension .foo in a directory that are in different directories underneath this base directory to files with different extension .bar.<br />4) Delete the original file from source control.<br />5) Add the copied file to the source control.<br />This could have been achieved manually or using a shell/perl script. Manually it would have taken me a long time, since I am not very comfortable with a shell or a perl script, thought I would write this in jython. It took me 10 minutes to come up with this script, and while doing so I found an extremely useful module, <a href="http://docs.python.org/lib/module-shutil.html">shutil</a>.  The script can be massaged a bit to make it more efficient.<br />Here&#8217;s the script that I wrote. </p>
<p><font color="#0000FF"><i>import os<br />import shutil<br /># define the source control commands here<br />delete = &#8220;p4 delete &#8220;<br />add = &#8220;p4 add &#8220;<br />forceSync = &#8220;p4 sync -f &#8220;<br />revert = &#8220;p4 revert &#8220;</p>
<p>def dirwalk(dir):<br />···&#8221;&#8217;walk a directory tree&#8221;&#8217;<br />···for f in os.listdir(dir):<br />······fullpath = os.path.join(dir, f)<br />······print &#8220;Looking at &#8220;+fullpath<br />······if os.path.isdir(fullpath) and not os.path.islink(fullpath):<br />·········dirwalk(fullpath)<br />·········if os.path.isfile(fullpath):<br />············s = String(fullpath)<br />············work(s, fullpath)         </p>
<p>def work(myStr, thePath):<br />···if myStr.endsWith(sys.argv[2]):<br />······# first revert<br />······theStr = String(revert)<br />······cStr = theStr.concat(myStr)<br />······Runtime.getRuntime().exec(cStr)<br />······# now force sync the file<br />······theStr = String(forceSync)<br />······cStr = theStr.concat(myStr)<br />······Runtime.getRuntime().exec(cStr)<br />······# now copy the file to a different extension<br />······_myStr = myStr.replaceAll(sys.argv[2],sys.argv[3])<br />······# copy the file to the new extension<br />······shutil.copy(myStr, _myStr)<br />······# now delete the file from source control<br />······theStr = String(delete)<br />······cStr = theStr.concat(myStr)<br />······Runtime.getRuntime().exec(cStr)<br />······# now add the new file<br />······theStr = String(add)<br />······cStr = theStr.concat(_myStr)<br />······Runtime.getRuntime().exec(cStr)</p>
<p>&#8220;&#8221;"<br />Usage:<br />java weblogic.WLST c:/scripts/p4files.py d:/myfiles .foo .bar<br />This will revert all files under myfiles directory from source control, force sync&#8217;s the files, <br />copy the file to the given extension, deletes the file from source control and add the new file<br />to source control<br />&#8220;&#8221;"<br />dirwalk(sys.argv[1])</i></font></p>
<p>As you can see Jython is not only useful to call into Java objects you can also use it to call into operating system for file manipulation and also use most of the python modules with utmost ease. <br />This is one of the many many uses of Jython.</p>
<p>_uacct = &#8220;UA-2684269-2&#8243;;<br />urchinTracker();</p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2006/02/15/jython-is-just-too-useful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WLST as a Jython Module</title>
		<link>http://ghattus.com/2006/01/06/wlst-as-a-jython-module/</link>
		<comments>http://ghattus.com/2006/01/06/wlst-as-a-jython-module/#comments</comments>
		<pubDate>Sat, 07 Jan 2006 03:08:00 +0000</pubDate>
		<dc:creator>sghattu</dc:creator>
				<category><![CDATA[jython]]></category>
		<category><![CDATA[wlst]]></category>

		<guid isPermaLink="false">http://ghattus.com/2006/01/wlst-as-a-jython-module/</guid>
		<description><![CDATA[Few questions that I answered about WLST as a module via various email queries recently. What is a Jython Module?In simple words, a jython Module is more or less like a Java class/object that you can import into other Modules. Lets say, you wrote a script/module &#8216;A.py&#8217; and you defined a function &#8216;myFunction&#8217;. Now you [...]]]></description>
			<content:encoded><![CDATA[<p>Few questions that I answered about WLST as a module via various email queries recently. </p>
<p><font color="#0000FF" size="2"><b>What is a Jython Module?</b></font><br />In simple words, a jython Module is more or less like a Java class/object that you can import into other Modules. Lets say, you wrote a script/module &#8216;A.py&#8217; and you defined a function &#8216;myFunction&#8217;. Now you can import this A.py into a different script, say B.py&#8217; and call the function &#8216;myFunction&#8217;. Here&#8217;s how you do it.</p>
<p>    <font color="#0000FF">A.py<br /></font>    &#8212;&#8212;-<br />    <font color="#800080"><i>def myFunction():<br />            ··print &#8220;Hello There!&#8221;</p>
<p>         def printFirstName(myName):<br />           ··print &#8220;Hello &#8220;+myName<br /></i><br /></font>    <font color="#0000FF">B.py</font><br />    &#8212;&#8212;<br />    <font color="#800080"><i>import A<br />    A.myFunction()<br />    A.printFirstName(&#8220;satya&#8221;)<br /></font></i><br />WLST provides a convienient way for you to import it as a module into your scripts and use all the WLST commands that are supported. The advantage of doing this is you can write Jython Modules without any WebLogic dependency and import WLST module into these modules. For example, now you can have another module C.py where you will import wlstModule.py and A.py.</p>
<p><font color="#0000FF">C.py</font><br />    &#8212;&#8212;<br />    <font color="#800080"><i>import A<br />import wlstModule.py as myWLST<br /># connect to the server<br />myWLST.connect(&#8216;weblogic&#8217;,'weblogic&#8217;,'t3://sghattu:7001&#8242;)<br /># call a function from module A<br />A.printFirstName(&#8220;satya&#8221;)<br />#start and edit session and create a server<br />myWLST.edit()<br />myWLST.startEdit()<br />newSvr = myWLST.cmo.createServer(&#8216;ms1&#8242;)<br />newSvr.setListenPort(8001)<br />myWLST.activate()<br />myWLST.disconnect()<br /></i><br /></font><br /><font color="#0000FF" size="2"><b>What is the difference between WLST as a Module and invoking WLST?</b></font><br />If you invoke WLST via &#8216;<i>java weblogic.WLST</i>&#8216;, WLST instantiates a Jython Interpreter, creates a WLST Namespace and installs all the WLST functions in it. You can import other modules, but you will not have access to WLST functions from these external modules because when you import other modules they will be imported into the Jython&#8217;s Default NameSpace not the WLST NameSpace. To use your modules in WLST namespace you will have to execute the module in wlst NameSpace using execfile(externalModule.py).</p>
<p><font color="#0000FF" size="2"><b>Where can I find WLST Module and are there any recommendations</b></font><br />WLST Module is under {WL_HOME}/common/wlst/modules/wlstModule.py. You can also generate one using the writeIniFile command.<br />If you are using WLST as a module, you should use <i>java org.python.util.jython</i> to invoke your scripts. Do not use <i>java weblogic.WLST</i> and import WLST as a module. This will import WLST Module into WLST NameSpace and if you mix the module calls with straight WLST calls, you will see some weird interactions. This is not recommended. Please use straight Jython if you are using WLST as a Module.</p>
<p>_uacct = &#8220;UA-2684269-2&#8243;;<br />urchinTracker();</p>
]]></content:encoded>
			<wfw:commentRss>http://ghattus.com/2006/01/06/wlst-as-a-jython-module/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
