Sharing code between server, client, and web



Hello everyone. This is a basic question of structure--something that
it's rather difficult to search for.

So, here's what there will be once this project is finished:

1) A server using Twisted and SQLAlchemy

2) A desktop client connecting to that server (with Twisted), using

3) A web interface using Pylons and SQLAlchemy

The web interface and desktop app will be accessing the same data, but
with different privileges and features. Twisted will be used to
shuttle objects back and forth (using Perspective Broker). So, what I
would really like to do is this:

1) Define the SQLAlchemy tables and models only once, and share that
between the server and Pylons

2) Define methods on the models that can be used from the web
interface and desktop app--meaning the models need to be shared (to
some extent) with the client.

Nothing is written yet, but I already have code from a current project
to make SQLAlchemy and Twisted's Perspective Broker play nicely
together (that was an interesting exercise). What I'm not sure about,
though, is the best way to share some of the code all around. I've
thought of two possible ways, but I don't particularly like either:

1) Make the entire directory structure a package, so I can use
relative imports. This has the drawback that I'd need to package most
or all of the server code in with the client, which I really don't
want to do.

2) Have a separate lib directory that's symlinked into each place that
it's needed. Does anyone see any major drawbacks to this one? It
just rubs me the wrong way...

So, thanks for your help in advance, and if you need any more
information, please don't hesitate to ask.



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question