site organization best practices

19 views
Skip to first unread message

Sells, Fred

unread,
Nov 14, 2011, 10:05:12 PM11/14/11
to django...@googlegroups.com

Please accept my apologies for “hijacking” a previous thread.  Offense was unintentional.  My original question is:

 

I build healthcare applications and the gov't regs require we log most

 user access to patient info.

 

Since I've only built one (rather large) Django app, my logging is in

 the same DB as my data and I use decorators in views.py to log all

 access.  There is only one table in it's own schema that is used for

 this.

 

Now I'm building additional, functionally unrelated projects but would

 like to use the same logging model.

 

We use MySQL and have very low throughput and use several databases

 (i.e. mysql schema's) on a single linux server.

 

Since this is used by several unrelated applications, I would

 appreciate some advice from more experienced developers on a good technique.

Please bear in mind that I'm the only Python/Django.SQL developer in

 my organization so there is not the need to coordinate with multiple

 independent teams..

 

Would you recommend:

a) Just duplicate the model definition in each app (i.e. move to

 separate file and import it for DRY) and use the ".using() clause or a

 db router?

b) Create a separate app, dedicated to this -- but what's the best way

 to do a "cross app" reference

c) create a separate site dedicated to this -- then should I use a url

 to pass it the logging data making it decoupled or is there a better

 way

 

Any insight would be appreciated.  As I said, I work solo at the

 office so this is my only way to collaborate with other professionals.

 

F

 

Mike Thon

unread,
Nov 15, 2011, 5:16:15 AM11/15/11
to django...@googlegroups.com
I'm no expert here but if it were me building this project, I'd build the logging mechanism as a separate app and still use the decorator as you are already doing. As for 'cross app reference' - you just import your logging app into your project they way you do any other app. Should be fairly simple to factor out your current logging code into a separate app.  Then it will be easier to reuse in other projects. 
best
Mike

Stuart Laughlin

unread,
Nov 15, 2011, 2:11:40 PM11/15/11
to Django users
FWIW I agree with Mike. It's difficult to advise without seeing
exactly what you're doing, but I think Mike's advice/approach is
sound.


--Stuart

Mike Dewhirst

unread,
Nov 15, 2011, 9:43:13 PM11/15/11
to django...@googlegroups.com
On 16/11/2011 6:11am, Stuart Laughlin wrote:
> FWIW I agree with Mike. It's difficult to advise without seeing
> exactly what you're doing, but I think Mike's advice/approach is
> sound.

I agree too. But in today's mail is a link to an answer to a similar
question about centralising control of login-required. It may be useful
to consider a middleware approach to logging.

See Colin Bean's email headed Re: Automatically direct unauthenticated
users to homepage

Cheers

Mike

Reply all
Reply to author
Forward
0 new messages