Documentum and Jython – part Deux

May 16, 2008 at 8:22 pm | Posted in Jython | 1 Comment
Tags: ,

In my first post about the joys of Jython and Documentum I just showed some bare bones code to login and perform an action. One of the things I like is the jython interpreter where you can effectively run DFC line-by-line at the command prompt and see the effect. However all that typing can get a little tedious so it makes sense to wrap up some of the useful stuff into a module that can be imported into Jython.

First lets see how we can wrap the DFC connection code into a function that can be called multiple times. Fire up the jython interpreter and enter the following:

>>> from com.documentum.com import DfClientX
>>> def connect(docbase, username, password):
...  cx=DfClientX()
...  c  =cx.getLocalClient()
...  li  =cx.getLoginInfo()
...  li.setUser(username)
...  li.setPassword(password)
...  s = c.newSession(docbase, li)
...  return s
...
>>>

The first line is the standard import of the DfClientX class from which we can dynamically create (directly or indirectly) most of the other DFC classes.

The second line is the way to create functions in Jython. The def keyword starts a function definition. It is followed by the function name and then the parameters in brackets – Jython is not strictly typed so we don’t need to specify types in the function definition. The line ends with a colon. This is the standard python/jython way of indicating a multi-line statement block; unlike java there are no curly brackets to delimit statement blocks. Following the function definition line each line of the function must be indented. Every indented line up to and including the return statement is part of the function (notice the interpreter changes the >>> to ...). The function definition is ended by a blank line – after this the interpreter returns to the >>>.

Now we can simply call the function like this:

>>> s1 = connect("mydocbase","dmadmin","dmadmin")
>>> s2 = connect("mydocbase","user1","user1pass")

to give us 2 sessions, one for dmadmin and one for user1.

Now we could use the session to create an object:

doc = s1.newObject("dm_document")
doc.setObjectName("my document")
doc.link("/cabinet1/folder2")
doc.save()

I think you get the idea!

But we don't want to have to create the connect function every time, so copy all the code into a separate file:

from com.documentum.com import DfClientX

def connect(docbase, username, password):
 cx=DfClientX()
 c  =cx.getLocalClient()
 li  =cx.getLoginInfo()
 li.setUser(username)
 li.setPassword(password)
 s = c.newSession(docbase, li)
 return s

Name it dctm.py (py is the standard python/jython script extension) and save it in the main Jython directory (where you installed jython which in my case is c:\jython2.2.1). Now restart the the jython interpreter and enter the following:

>>> import dctm
>>> s = dctm.connect("docbase2","dmadmin","dmadmin")

The import statement pulls in the code from the dctm.py script and makes the function available via the dctm namespace. Once we have the IDfSession object s we can again do some work:

doc2 = s.newObject("dm_document")
doc2.setObjectName("another document")
doc2.save()

Enjoy!

Advertisements

50,000 and counting

May 14, 2008 at 8:51 pm | Posted in Object Replication | 5 Comments

16 months on, the blog has finally clocked up 50,000 hits! My original motiviation for blogging was to be able to write something less formal and that took less time to write and format than the articles I was putting out on the Xense website. At the time there were very few Documentum blogs (Johnny Gee’s was probably the only one I noticed regularly) and I was keen to do something deeply technical in a similar vein to Jonathan Lewis (Oracle) or Mark Russinovitch (Windows).

One of the things that has surprised is just how much effort it is to keep finding the time and inspiration to write. Back in January 2007 I managed more than one article a week, these days I think I’m doing well if I can do a couple a month. Partly this is because I had a number of small pieces of research that were already done and simply needed to be turned into words. These days I still have loads of ideas but so little time to follow up and do the research.

The focus has changed a little bit too. When I started I had been spending a lot of time knee-deep in object replication. Frankly I don’t like the technology and would be very hesitant to recommend it on a project. Part of the problem is the obscurity of the implementation. The serious guts of the workings are embedded deep into the Content Server C/C++ code so it’s not easy to work out what is going on when it fails unless you want to dive into the assembly-level debugger (which I have resorted to on occasion).

The other problem is the dump and load process that underlies it. Dump and load is simply too flaky for a reliable replication solution. I managed to find various ways of crashing the content server (which is catastrophic on the thread-based windows implementation) which I wrote up for a client in a document called ‘Killing the Content Server’. I sent it to Documentum support too.

Here’s to the next 50,000!

BTW I’ve added in a blogroll entry for Andrew Binstock – and excellent blog covering all sorts of things Java Development related. Very honest, very open.

Documentum 5 Profiler

May 8, 2008 at 10:06 am | Posted in Performance, Xense Profiler | Leave a comment

Xense Profiler v1.3, the Documentum 5 performance profiler, has now been officially released after an extended and successful beta period. During that time there have been no bugs or issues reported.

If you need to quickly analyse systems for performance problems Xense Profiler is the fastest and most convenient tool for the job. No need to import files into Excel for analysis; the Xense Profiler, dmclprof, analyses DMCL trace files and creates HTML-based reports that provide the information you need to diagnose system performance problems.

One of the new features of v1.3 is a Top Queries report. In previous versions you had to rely on scanning through the Query Summary report to find long-running queries; for large traces with lots of queries this could be inconvenient.

Top Queries reports the Top 20 longest-running queries. In this case longest-running means the queries taking the most time to complete. Since its inception Xense Profiler has calculated the true cost of a query. Most other approaches to performance analysis simply record the time taken to complete a DfQuery.execute() call, Xense Profiler aggregates the duration of the execute() call and all the corresponding next() calls as well. Only in this way can you be sure that you really have identified the long-running queries in your system. The documentation is now on-line with examples of the reports.

If you are interested in using Xense Profiler for your systems you should check out the information on the Xense website.

Where is dmcl.ini in D6?

May 2, 2008 at 6:05 am | Posted in D6 | 4 Comments

Always interesting to look at the search terms people are using when they reach my blog. One I noticed this morning is ‘documentum dfc 6.0 install dmcl.ini’. Looks like someone is installing D6 and wants to know where the dmcl.ini is.

The DMCL and the dmcl.ini has been part of Documentum since I started working with it 9 years ago, but D6 breaks all that. For the record there is no dmcl.ini in D6 – all the parameters that used to be in dmcl.ini now have equivalents in the dfc.properties.

Blog at WordPress.com.
Entries and comments feeds.