Search DominoPower's 11,441 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
Using Python to create a command line interpreter for Notes (continued)

Python has identical syntax for calling Notes objects by either method. Using PythonWin, the commands required are:

import win32com.client
sess=win32com.client.Dispatch("Lotus.NotesSession")

Typing the above on its own will use late-bound COM. To use early-bound, there's a Python script called "make.py" built into PythonWin that will configure Python for any available COM class. To make it even easier, PythonWin includes this in the standard menu. To use it with Notes, select "Lotus Domino Objects" from the list offered. Once make.py has been run, all calls to those objects will use the more efficient early-bound COM calls.

If you wish to automate this process of registering the Domino classes, perhaps as part of a Python program interfacing to Notes, then put the following lines in your code:

from win32com.client import gencache
gencache.EnsureModule('�-2EED-1069-BF5D-00DD011186B7}', 0, 1, 0)

Since Python now knows all about the Notes objects, PythonWin can also give you the same helpful pop-up class boxes for Notes as it does for internal Python classes. Figure C shows the box that appears when the NotesSession object "sess" is typed in.

FIGURE C


Pop-up class browser is a standard part of PythonWin. Roll over picture for a larger image.

Once the "sess" object is defined, it's possible to use a much more familiar syntax to call other objects. In this example, a database is opened and the title is examined and changed:

>>> db=sess.GetDatabase("","log.nsf")
>>> db.Title
u'Notes Log'
>>> db.Title='Notes Log (Python)'
>>> db.Title
u'Notes Log (Python)'

There are three things to note from this example:

  • Python lets you omit the print statement to examine an object;

  • Notes returns strings as Unicode rather than plain ASCII while Python has simple functions to switch between these;

  • It's only possible to create one new Notes object using COM (whether you use Visual Basic, Python, or any other language), and that's the NotesSession.

The objects which are typically created using a "Dim New" statement in LotusScript, such as NotesDatabase, are created instead using methods of NotesSession.

Using Java
PythonWin is just one of many implementations of Python on various platforms. One recent addition is the Java based JPython. This is supplied as a JAR file of 100% Pure Java code. It enables a Python interpreter to operate within any JVM (Java Virtual Machine) on any system, or for a Java applet on a Web page to execute Python script code rather than Java.

Like PythonWin, JPython is both a command line interpreter and a full language interpreter, with the difference that now you have all the Java classes--Swing, JDBC (Java Data Base Connectivity), Domino, LotusXSL and thousands of others--available to browse and play with on the command line. And unlike COM, this will run on Linux, Solaris, Macintosh, or any other Java supporting platform.


« Previous  ·  1  ·  2  ·  3  ·  4  ·  5  ·  6  ·  Next »
Other articles you might like
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.

The many included activities and demos will make you a pro! Expert instructor help is a click away.

Click here to try a FREE demo course!!

-- Advertisement --

Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.

Register by April 10 to save $200.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login