472,351 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

AW: [Zope3-Users] Python Package Construction

Hi Tim
Betreff: [Zope3-Users] Python Package Construction

Hi All,

I would like feedback on the proper/best 'Pythonic' approach.

This is a rather subjective question. Where is the trade-off
between package name lengths and faithfulness to the specifications?

[Discussion follows]

I am implementing a set of specifications for healthcare IT
for Python programmers to be able to develop interoperable
healthcare applications.
I am using ZCA (aka.Zope3) extensively.

My desire is to implement the specs as faithfully as possible for two
reasons:
1) teachability - how easy/difficult is it to teach the
framework and specifications to new developers?
2) maintainability - which approach, if either, will make it
easier to maintain the framework if/when the specifications change?

My first pass was to develop a skeleton of the specs using
Interfaces from the ZCA approach and then the implementations
following the document structure of the specs.

The specs are available via SVN at:
http://www.openehr.org/svn/specifica...ublishing/arch
itecture/

It is best to probably use real examples. Following the
document structure for packaging AND using the ZCA convention
of having a sub-directory for interfaces caused massive
circular import issues due to some classes being used in the
interface definition of classes inside the same interface
file being imported into the implementation file. If that
sounds confusing; it is. It was confusing to write too. :-)
If anyone has questions I'll try to expand.

It is best to probably use specific, real examples.
http://www.openehr.org/svn/specifica...ublishing/arch
itecture/rm/data_types_im.pdf

(note class names are converted from the upper case,
underscore separated style to CamelCase)

The package openehr.rm.datatypes.text defines the
implementation class CodePhrase. The associated interface
file openehr.rm.datatypes.interfaces.text needed CodePhrase
as an attribute type in DvCodedText and TermMapping needs
both CodePhrase and DvCodedText. This quickly got out of control.

So my solution to solving the circular imports is to take
each interface and implementation and put them into one file.
Research tells me that this is probably the second mostly
popular ZCA approach. So, ICodePhrase and CodePhrase are now
in openehr/rm/datatypes/codephrase.py, DvCodeText and
IDvCodedText in openehr/rm/datatypes/dvcodedtext.py, etc.

But wait, now I don't have a 'text package'. So if
codephrase.py and dvcodedtext.py were in
openehr/rm/datatypes/text/ that would solve the problem.
BUT! Throughout the specs many of the names are VERY long
already. Adding another package name that is from 4 - 15 (or
more) characters long adds to the length of already long
import statements, i.e.

(sorry for the email line wraps)

from openehr.am.archetype.creferenceobject import
ICReferenceObject,CReferenceObject

should really be

from openehr.am.archetype.constraintmodel.creferenceobj ect
import ICReferenceObject,CReferenceObject

Thoughts, opinions and jeers all gratefully accepted. :-)
For a usecase like this, I personaly recommend to
defina all interfaces in one module which probably
is a namespace if you need alot of interfaces to define.

e.g.

openehr.interfaces.foobar.IFooBar

the reason why:

- spearate interface from implementation. That's an
important aspect in a component architecture. If you
define your implementation and interfaces in one file,
then you don't need a component architecture.

- interfaces are separated in a well know place.

This means if you define a module and you like to import
an interface you can import just one line:

from openehr import interfaces

Which makes it very simple.
Regards
Roger Ineichen
--Tim



--
Timothy Cook, MSc
Health Informatics Research & Development Services LinkedIn
Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
************************************************** ************
*You may get my Public GPG key from popular keyservers or *
*from this link http://timothywayne.cook.googlepages.com/home*
************************************************** ************
Jun 27 '08 #1
0 979

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Debian User | last post by:
Hi, I'm trying to discover a memory leak on a program of mine. I've taken several approaches, but the leak still resists to appear. First of...
0
by: Aroldo Souza-Leite | last post by:
Hi, The Rheinland section of the German Zope User Group (dzugRheinland) is announcing a Zope 3 Sprint on Producuts for December 2003. Sprint...
0
by: JZ | last post by:
I heard Zope3 has implemented CMF inside. What about Plone? Will it be added also? -- JZ
30
by: Sean R. Lynch | last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm on the way to making the modifications necessary to create a...
8
by: Jean | last post by:
Hi. I am new to Python, but very eager to learn. I've browsed many postings and found conflicting opinions on the best backend and development...
2
by: Mir Nazim | last post by:
Hi, I wanted to know what will happen to plone once Zope3 will be official version. Is plone being ported to Zope3. I googled it but did not come...
7
by: Markus Wankus | last post by:
Hi All, Does anyone know of any good Zope3 examples? I'm new to Zope and I just want to start with a simple website, and later move on to a more...
0
by: Chris Calloway | last post by:
Registration ends Friday: http://trizpug.org/boot-camp/camp5 -- Sincerely, Chris Calloway http://www.seacoos.org office: 332 Chapman Hall...
2
by: Paul McGuire | last post by:
I just stumbled upon a great-looking project, to make Zope3 more approachable to mere mortals such as myself. Echoing the ROR mantra of...
11
by: Grzegorz Staniak | last post by:
Hi, In a couple of weeks I'm starting a medium-size project (using a web framework) involving a workflow implementation. Are you aware of any...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.