Semprini
unread,Mar 29, 2011, 1:31:07 PM3/29/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to UML to Django
I've changed the uml2djlib.py to use the lxml library since compiling
libxml2 for windows 64 bit is a pain.
Here's the changes:
import lxml.etree
def generate_code(app_name):
xmi_file = '%s.xmi' % app_name
transform('uml2dj/xmi2djmodels.xsl', xmi_file, app_name+'/
_models.py')
transform('uml2dj/xmi2djmodels_generic.xsl', xmi_file, app_name+'/
models_generic.py')
transform('uml2dj/xmi2djadmin.xsl', xmi_file, app_name+'/
admin.py')
transform('uml2dj/xmi2djadmin_custom.xsl', xmi_file, app_name+'/
_admin_custom.py')
transform('uml2dj/xmi2djadmin_generic.xsl', xmi_file, app_name+'/
admin_generic.py')
def transform(stylesheet, source, target):
doc = lxml.etree.parse(source)
styledoc = lxml.etree.parse(stylesheet)
style = lxml.etree.XSLT(styledoc)
result = style.apply(doc)
f = open(target,"w")
f.write(style.tostring(result))
f.close()