I have a general question about how people manage "reusable apps" in
the web app world.  Let me give an example of what I am encountering,
maybe those of you with experience can comment.

I'm developing an app that is a task management app.  IE, an
engineering manger creates tasks, spawns them off to engineers,
engineers generate results, record those results in the app and the
manager sits in a meeting and quickly runs through the tasks
(displayed by my webapp, updated by the engineers and managers), fand
igures out "what's next", creating new tasks on the fly.

I've recently integrated Eric Florenzano's threaded comments app into
my app (thanks much to Eric!).  So far I've kept the threaded
threadedcomments functionality fairly decoupled from my own
"taskmanager" app.  For example, when the user adds a comment the post
goes to a URL that is defined in threadedcomments/urls.py, and then
gets sent the views.py function in threadecomments/views.py code.
However, as I've continued developing my UI,  I'm finding that it is
hard to keep them so decoupled.  For example, one of the html pages
rendered to my users is similar to the django admin changelist.  It
shows a filtered set of tasks and for each task shows a very brief
horizontal summary of the most important aspects of the task (task
name, owner, deadline, etc.).  Now that I have this nice comment app I
find that I want the user to be able to easly view the most recent
comment associated with the task.  No problem there. In my
"changelist" view I now display a "date modified" column, and in that
column I render the date of the last comment.  When the user mouses
over that date, they get a jquery "cluetip" (tooltip) that contains
the most recent comment.  All good.  However, the next thing I realize
I now need is the ability to sort on that column . So therein lies the
problem.

All other columns can be easily sorted on using order_by() because
they are fields in my Task model.  But the date of the last comment is
not.  I can of course create a field in my Task object that records
the date of a comment whenever a comment is added, but since a comment
is added via a threadecomments/views.py function, that would mean
doing one of the following:

 * modify the threadedcomments views.py code that receives the POST
for a new comment, and make it just know about my Task model (and save
the comment date and perhaps a id for the last comment in my Task
model).

 * modify the threadedcomments views.py code to take a callback
function as an argument - that callback function could do my Task
specific stuff as described above, but this would keep it more
encapsulated within my Task app (but of course I would still have to
modify threadecomments to take the callback arg)

 * give up on using the threadedcomments views.py function that
creates a new comment, and just do the same stuff in my Task app (ie,
handle the POST of a new comment), using the models specified by
threadedcomment, but also saving the date and id of last comment in my
Task object.

  * Do my sort ordering with something more custom than the standard
order_by() - ie, something that looks at the date of the last
ThreadedComment object that is associated with the task.  I'm sure
there must be a way to do this, but I'm concerned it could be very
slow, not sure though, perhaps there is sql magic I could do.

I can see other times when I will have similar problems, as well.  For
example, when a task is added, I would like the user to be able to add
a comment along with the other data - this seems like it cause a
similar problem.  I already have a "task add" form - so it seems that
I need to integrate the comment into my own form, which means I'd have
to deal with creation of that comment within my own views.py code, and
not just rely on the views.py in the threadedcomments app.


My goal is to have clean and reusable code, follow DRY principles,
etc..  I'd like to be able to integrate a new version of
threadedcomments into my app, if it becomes available, but I'm
concerned that I'm proceeding down a path that will make that
difficult, so I'm curious if any of you with lots of web app
experience can lend any insights toward the best way to manage this
sort of issue.

Sorry for the long post here.  Hopefully this is an interesting topic
to some of you out there!

Margie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to