I have been looking for a good class diagram generator for my jython / python work and stumbled on PyNSource. Here is a quick list of features:
A python code scanner and UML modelling tool that generates
UML diagram models that you can layout, arrange and print out.
UML text diagrams, which you can paste into your source code for documentation purposes.
Java or Delphi code (which can be subsequently imported into more sophisticated UML modelling tools, like Enterprise Architect or ESS-Model (free).)
Resilient: doesn't import the python files, thus will never get "stuck" when syntax is wrong.
Recognises inheritance and composition relationships
Detects the cardinality of associations e.g. one to one or 1..* etc
Optionally treat modules as classes - creating a pseudo class for each module - module variables and functions are treated as Attributes and methods of a class
Has been developed using unit tests (supplied) so that you can trust it just that little bit more ;-)
I gave it a quick try and here is what it looks like (click on the image to see the larger text):
I know that a number of python ide's have class browsers built in but how about a class diagram a-la uml as well? I think that would be pretty handy. Please let me know if there are are other python aware tools out there.
We interrupt your regularly scheduled Jython coverage to bring you this therapeutic rant:
OK, so if you are using SQLObject_ with MySQL 4.X and you notice that queries executed after table updates do not reflect the changes .... TURN OFF _CACHE_VALUES for your database classes (you do this by defining the following class attribute:
_cache_values = False
Since MySQL does autocommit by default your database changes are invisible to queries if you don't do this ... That only cost me several hours. Ok I feel better now.
And now back to your regularly scheduled Jython coverage.
Scripting LDAP with Jython -- Load Java Objects from LDAP
A common way to store user preference data for applications is to store them in LDAP as a serialized Java Hastable object. The application then reads that back from ldap on startup using the authenticated userid as the key. Its a convenient way to store application settings. But what if you need to adjust or migrate settings from one place to the other? Here is an approach to reading that data out using Jython. Look for a future post about how to save it back using the context's bind method ...
# Jython LDAP - Retrieve Stored Object from LDAP Example
from javax.naming import *
from java.util import *
from javax.naming.directory import *
# Credentials to access LDAP
user = "cn=master"
passwd = "password"
# Setup LDAP Context Options
settings = Hashtable()
# Connect to LDAP Server
ctx = InitialDirContext(settings)
# load the java Hashtable out of the ldap server
prefs = ctx.lookup("cn=ccm_root,ou=Preferences,dc=Company,dc=com")
for pref in prefs.keys():
print "PREF: %s\n VALUE: %s " % (pref, prefs[pref])
Here is a great new Jython article by Barry Feigenbaum over on IBM's developerWorks. Check it out.
alt.lang.jre: Get to know Jython Get to know Jython, in this first article in our new series introducing alternate languages for the Java Runtime Environment, "alt.lang.jre". Jython is an implementation of the popular scripting language Python, but running on a JVM. For Python developers Jython is the best possible entry point to the Java platform; for Java developers it may be the strongest incentive to learn another language. Frequent developerWorks contributor and alternate language enthusiast Barry Feigenbaum introduces Jython and shows you what it can do to enhance your productivity on the Java platform.
Thanks to reader feedback including several of the authors I have corrected the bibliography (its pretty neat to receieve feedback from the cited authors. You have to love the 'net.). Additionally, I have added several older articles on JPython which preceeded Jython. Again, if there is anything missing or incorrect please let me know either in comments here or via email to etaekema-at-earthlink-dot-net.