473,320 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1039

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 all, I've tried to use the garbage collector to...
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 Topics: porting products from Zope 2 to Zope 3;...
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 capabilities-based restricted execution system. The idea is to...
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 setup. In fact, I am more confused now that when I...
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 accross anything stating the plone's migration...
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 complex site with interactive calendar,...
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 phone: (919) 962-4323
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 "convention over configuration", the Grok project (http://...
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 open source workflow engines/libraries that I could...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.