https://www.zkoss.org/_w/index.php?title=Small_Talks/2010/May/Python_With_ZK_Part2&feed=atom&action=history
Small Talks/2010/May/Python With ZK Part2 - Revision history
2024-03-28T10:08:11Z
Revision history for this page on the wiki
MediaWiki 1.35.1
https://www.zkoss.org/_w/index.php?title=Small_Talks/2010/May/Python_With_ZK_Part2&diff=23790&oldid=prev
Southerncrossie: /* See Also */
2011-12-08T08:17:13Z
<p><span dir="auto"><span class="autocomment">See Also</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 08:17, 8 December 2011</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l182" >Line 182:</td>
<td colspan="2" class="diff-lineno">Line 182:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== See Also ===</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== See Also ===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*[[Small_Talks/2010/February/Python_With_ZK|Python With ZK]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*[[Small_Talks/2010/February/Python_With_ZK|Python With ZK]]</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>*[[Small_Talks/2011/December/Python_With_ZK_Part3 Python With ZK Part3]]</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>*[[Small_Talks/2011/December/Python_With_ZK_Part3<ins class="diffchange diffchange-inline">|</ins>Python With ZK Part3]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Python]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Python]]</div></td></tr>
</table>
Southerncrossie
https://www.zkoss.org/_w/index.php?title=Small_Talks/2010/May/Python_With_ZK_Part2&diff=23789&oldid=prev
Southerncrossie at 08:16, 8 December 2011
2011-12-08T08:16:23Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 08:16, 8 December 2011</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l182" >Line 182:</td>
<td colspan="2" class="diff-lineno">Line 182:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== See Also ===</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== See Also ===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*[[Small_Talks/2010/February/Python_With_ZK|Python With ZK]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*[[Small_Talks/2010/February/Python_With_ZK|Python With ZK]]</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">*[[Small_Talks/2011/December/Python_With_ZK_Part3 Python With ZK Part3]]</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Python]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Python]]</div></td></tr>
</table>
Southerncrossie
https://www.zkoss.org/_w/index.php?title=Small_Talks/2010/May/Python_With_ZK_Part2&diff=12885&oldid=prev
Char: /* See Also */
2010-11-30T03:18:17Z
<p><span dir="auto"><span class="autocomment">See Also</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 03:18, 30 November 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l181" >Line 181:</td>
<td colspan="2" class="diff-lineno">Line 181:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== See Also ===</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== See Also ===</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>*[[Python With ZK]]</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>*[[<ins class="diffchange diffchange-inline">Small_Talks/2010/February/Python_With_ZK|</ins>Python With ZK]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Python]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Python]]</div></td></tr>
</table>
Char
https://www.zkoss.org/_w/index.php?title=Small_Talks/2010/May/Python_With_ZK_Part2&diff=12884&oldid=prev
Char: /* Python With ZK Part2 */
2010-11-30T03:17:38Z
<p><span dir="auto"><span class="autocomment">Python With ZK Part2</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 03:17, 30 November 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l7" >Line 7:</td>
<td colspan="2" class="diff-lineno">Line 7:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Python With ZK Part2 =</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Python With ZK Part2 =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>In a previous smalltalk [[Python With ZK]] I showed how to separate Python code from ZUL code together with a little MVC and "design by convention".</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>In a previous smalltalk [[<ins class="diffchange diffchange-inline">Small_Talks/2010/February/Python_With_ZK|</ins>Python With ZK]] I showed how to separate Python code from ZUL code together with a little MVC and "design by convention".</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This smalltalk builds on the previous one and adds model code to access a Postgresql database.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This smalltalk builds on the previous one and adds model code to access a Postgresql database.</div></td></tr>
</table>
Char
https://www.zkoss.org/_w/index.php?title=Small_Talks/2010/May/Python_With_ZK_Part2&diff=7637&oldid=prev
Elton776: moved Small Talks/Python With ZK Part2 to Small Talks/2010/May/Python With ZK Part2
2010-09-20T09:43:30Z
<p>moved <a href="/wiki/Small_Talks/Python_With_ZK_Part2" class="mw-redirect" title="Small Talks/Python With ZK Part2">Small Talks/Python With ZK Part2</a> to <a href="/wiki/Small_Talks/2010/May/Python_With_ZK_Part2" title="Small Talks/2010/May/Python With ZK Part2">Small Talks/2010/May/Python With ZK Part2</a></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 09:43, 20 September 2010</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Elton776
https://www.zkoss.org/_w/index.php?title=Small_Talks/2010/May/Python_With_ZK_Part2&diff=6072&oldid=prev
Elton776: Created page with '{{Template:Smalltalk_Author| |author=BobZK |date=May 11, 2010 |version=ZK 3.6+ }} = Python With ZK Part2 = In a previous smalltalk Python With ZK I showed how to separate P…'
2010-09-13T04:38:42Z
<p>Created page with '{{Template:Smalltalk_Author| |author=BobZK |date=May 11, 2010 |version=ZK 3.6+ }} = Python With ZK Part2 = In a previous smalltalk <a href="/_w/index.php?title=Python_With_ZK&action=edit&redlink=1" class="new" title="Python With ZK (page does not exist)">Python With ZK</a> I showed how to separate P…'</p>
<p><b>New page</b></p><div>{{Template:Smalltalk_Author|<br />
|author=BobZK<br />
|date=May 11, 2010<br />
|version=ZK 3.6+<br />
}}<br />
<br />
= Python With ZK Part2 =<br />
<br />
In a previous smalltalk [[Python With ZK]] I showed how to separate Python code from ZUL code together with a little MVC and "design by convention".<br />
<br />
This smalltalk builds on the previous one and adds model code to access a Postgresql database.<br />
<br />
=== Correction to PythonForwardComposer ===<br />
<br />
There were two minor mistakes in the previous smalltalk in the code for PythonForwardComposer. Below is the corrected code -<br />
<br />
=== Python composer - PythonForwardComposer.py ===<br />
<br />
<source lang="python"><br />
from org.zkoss.zk.ui.util import GenericForwardComposer # removed ";" from end of line<br />
class PythonForwardComposer(GenericForwardComposer):<br />
<br />
def __init__(self):<br />
GenericForwardComposer.__init__(self, "_")<br />
<br />
def doAfterCompose(self, component):<br />
GenericForwardComposer.doAfterCompose(self, component)<br />
for method in dir(self):<br />
if callable(getattr(self, method)):<br />
if method.startswith("on") and '_' in method: # allow names that already have an underscore<br />
idx = method.index('_')<br />
comp = component.getFellowIfAny(method[idx + 1:])<br />
if comp != None:<br />
comp.addForward(method[:idx], component, method)<br />
component.addEventListener(method, self)<br />
<br />
def onEvent(self, evt):<br />
if callable(getattr(self, evt.name)):<br />
getattr(self, evt.name)(evt)<br />
</source><br />
<br />
Both changes from the original are commented.<br />
<br />
=== findairport.zul ===<br />
<br />
A fairly simple bit of ZUL (with the appropriate includes) that allows the user to enter an airport code and the airport name is returned.<br />
<br />
<source lang="xml"><br />
<?page title="Find Airports (Model/View/Contoller)" contentType="text/html;charset=UTF-8"?><br />
<zk><br />
<br />
<zscript src="PythonForwardComposer.py" language="python"></zscript><br />
<zscript src="BobModel.py" language="python"></zscript><br />
<zscript src="BobController.py" language="python"></zscript><br />
<br />
<window id="mywin" title="Find Airports" border="normal" height="200px"<br />
apply="${BobController}" width="200px" closable="true"<br />
sizable="true"><br />
Find an Airport:<br />
<label id="lMessage"/><br />
<textbox id="txMessage"/><br />
<button id="okButton" label="Go Find It"/><br />
</window><br />
</zk><br />
</source><br />
Notice again the use of 'apply="${BobController}"' on the window. Also the ID's on the various ZUL components.<br />
<br />
The screen should look like -<br />
<br />
[[Image:Screenshot-4.png]]<br />
<br />
=== BobController.py ===<br />
Now for our controller code. <br />
<source lang="python"><br />
from org.zkoss.zk.ui.event import Events<br />
<br />
class BobController(PythonForwardComposer):<br />
<br />
def __init__(self):<br />
self.model = BobModel()<br />
<br />
def onClick_okButton(self, event):<br />
message = txMessage.getValue().upper()<br />
lMessage.setValue(self.model.getAirport(message))<br />
<br />
def onClose_mywin(self, event):<br />
Events.getRealOrigin(event).stopPropagation()<br />
return False<br />
</source><br />
Notice how we instantiate the model code (BobModel) in the __init__ method.<br />
<br />
The onClick method gets control when the OK button is clicked, it gets the entered airport code and then invokes the getAirport method in BobModel, passing to it the airport code and getting the airport name in return. The airport name is placed directly into the ZUL variable "lMessage".<br />
<br />
The onClose method is there to show you how any ZUL component can have a method in BobController. In this case it simply ignores the close event.<br />
<br />
Notice again how we simply use "txMessage" and "lMessage" as defined in the ZUL without complicated access code. The auto-wiring of PythonForwardComposer and "design by convention" make access to these variables simple.<br />
<br />
=== BobModel.py ===<br />
Now we need our model code -<br />
<source lang="python"><br />
<br />
from com.ziclix.python.sql import zxJDBC<br />
<br />
class Select:<br />
__STATIC = 0<br />
__DYNAMIC = 1<br />
__jndiName = "java:comp/env/jdbc/mydatabase"<br />
__factory = "com.sun.jndi.fscontext.RefFSContextFactory"<br />
<br />
def __init__(self, select):<br />
self.select = select<br />
<br />
def runSelect(self, variables):<br />
try: <br />
conn = None<br />
cur = None <br />
result = [] # a list<br />
result_dict = {} # a dict<br />
<br />
conn = zxJDBC.lookup(Select.__jndiName, INITIAL_CONTEXT_FACTORY=Select.__factory)<br />
cur = conn.cursor(Select.__DYNAMIC)<br />
cur.execute(self.select, variables)<br />
<br />
rows = cur.fetchall()<br />
if cur.rowcount == 0:<br />
return None<br />
<br />
for row in rows:<br />
result_dict = {}<br />
for i, column in enumerate(row):<br />
result_dict[cur.description[i][0]] = column<br />
result.append(result_dict)<br />
return tuple(result)<br />
<br />
finally:<br />
if cur is not None:<br />
cur.close()<br />
cur = None<br />
if conn is not None:<br />
conn.close()<br />
conn = None <br />
<br />
class BobModel:<br />
<br />
def getAirport(self, airport):<br />
a = Select("select a_name from f_airports where a_code = ?;")<br />
rowset = a.runSelect([airport])<br />
if rowset is None:<br />
return "Not Found"<br />
else:<br />
return rowset[0]['a_name']<br />
</source><br />
You can see in class BobModel in method getAirport that we first instantiate a select object ("a") and then run that select with the airport code as the variable.<br />
<br />
I am not going to say much more about this code, I'm sure other people would code it differently, but it does work It uses Postgresql (but can be changed easily to any other DB) and zxJDBC with tomcat connection pooling. By coding it in such a manner, we ensure that we never hold a connection longer than absolutely necessary and that we always release the connection.<br />
<br />
The appropriate context code needs entering into context.xml file in the META-INF directory (WebContent/META-INF/context.xml) -<br />
<br />
=== context.xml ===<br />
<br />
<source lang="xml"><br />
<?xml version="1.0" encoding="UTF-8"?><br />
<Context docBase="TEST" path="/TEST" debug="5" reloadable="true" crossContext="true"><br />
<Resource name="jdbc/mydatabase" username="myname" password="mypassword"<br />
url="jdbc:postgresql://localhost/mydatabase"<br />
auth="Container" defaultAutoCommit="false"<br />
driverClassName="org.postgresql.Driver" maxActive="20"<br />
type="javax.sql.DataSource" /><br />
</Context><br />
</source><br />
<br />
The code in context.xml is the only code you need to change to use the same zul, controller and model code with a different database server (eg. mysql).<br />
<br />
Of course you will need to set up your own database (mydatabase) and f_airports table with an a_code column and an a_name column, if you really want to test the code.<br />
<br />
=== Conclusion ===<br />
<br />
it is possible to use ZK with Python in a Model-View-Controller fashion and keep the code separate from each other. You can easily set this up in Eclipse and use all the highlighting and code completion assistance of Eclipse, ZK and Pydev.<br />
<br />
The only concerns with this approach are the overhead of using Python and the security implications of having code in the WebContent directory. However with a bit of effort it is possible to overcome the security problem (more of this in a later smalltalk perhaps). The performance penalty really is not too bad. In most cases it can be ignored.<br />
<br />
=== See Also ===<br />
*[[Python With ZK]]<br />
<br />
[[Category:Python]]<br />
[[Category: Overview]]<br />
{{Template:CommentedSmalltalk_Footer|<br />
|name=BobZK<br />
}}</div>
Elton776