Hi,

I'm a bit stuck with the design of a system and so I was wondering if
someone could give some advice.

The system works as follows. Users can create documents, which are
stored in a Django model. To ensure there's no conflict, a document
can be modified only by one user at a time.
The edition of a document is made via a Flex application that
communicates with the server via Ajax.
When a user has finished modifying a document, the document is
released and another user can modify it. Finally, if a user wants to
open a document, but that document is currently being edited by
someone else, then the document would be opened in read-only mode,
until the lock is eventually released.

So far, I'm planning to have something like this:

class Document(models.Model):
    content = models.CharField()
    current_user = models.ForeignKey(User)
    lock_timestamp = models.DateTimeField()

As I see it, when the document is first opened, it is locked by
setting 'current_user' to request.user and 'lock_timestamp' to the
current time. Then, the frontend application keeps sending an ajax
request every 30 seconds to the remind the server that it is modifying
the document. So, the lock's timestamp is refreshed every 30 seconds
that the document is being used. When the frontend app is closed, the
timestamp is not refreshed any more, so if another user makes the
request at least 30 seconds later, the document will be released and
locked to him.

Does that sound viable? Performance-wise, is that a good system? If
not, would you have any other approach to suggest?

Thanks a lot for your help.

Regards,

Julien
--~--~---------~--~----~------------~-------~--~----~
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