Re: Locking a page?

2007-09-07 Thread jose

Hi all,
First thanks for the suggestions, after reading what has been posted
and giving it more thought this is how I think I am going to handle
page locking.

1) when a user enters the page to edit it, I will create a lock in a
lock table in my database.  This way of someone else whats to edit the
same page I can tell them that it is being edited by someone else and
just let them view the data as readonly

2) I will use some javascript to keep track of the person doing the
edits.  I am going to use window.onload to start a reminder timer
giving the user say 30 min to do their edits.  after the 30 min I will
open a dialog which will launch yet another timer.  one - if the user
ignores the reminder after say 5 min it will reload the page and
trigger some cleanup (see 3 below).  If the user is not done, closing
the dialog will cancel this timed event and let the user keep editing
the page

3) I am going to use window.onbeforeunload to find out when a user has
left the editing page, and fire an ajax call to clean up the database
locks.

I've not actually written all the locking code yet just been playing
with the timers and onbeforeunload and I think it will work.  I'll
post some working code if it works or let you all know if it does not
work

Any dialog about this or other approaches would be great.

Jose


On Sep 6, 1:07 pm, Jose Galvez [EMAIL PROTECTED] wrote:
 Hi all, I'm hunting for advice.  I am looking for a way to lock a webpage
 so that only only one person at a time can edit database data.  Here is the
 scenario, I have a database with a limited number of users who have write
 access to the database, what I'd like to do is lock the editing page so that
 if one of my users is editing a page then the other users will not be able
 to edit the same page(data) at the same time.  I know that this is what
 transactions are for in a database, but what I want to avoid is two people
 looking at the same unedited data and then editing it.  I guess what I
 really want to is lock a database when I use starts editing the data.  The
 issues are:
 1) How to make sure someone exits the edit mode nicely? what happens if they
 enter the edit page, do nothing and just close the browser, I don't what to
 leave the table locked
 2) if the table is locked I would still like to let users view the data in
 real time, jut not edit it.

 I've used a lock table for this in the past, but the issue that I've never
 figured out is how to make sure someone still needs the lock.  Again number
 (1) from above.

 I hope that this makes sense, I'll be using sqlalchemy and postgres on the
 back end

 thanks for any and all advice
 jose


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Locking a page?

2007-09-06 Thread Jose Galvez
Hi all, I'm hunting for advice.  I am looking for a way to lock a webpage
so that only only one person at a time can edit database data.  Here is the
scenario, I have a database with a limited number of users who have write
access to the database, what I'd like to do is lock the editing page so that
if one of my users is editing a page then the other users will not be able
to edit the same page(data) at the same time.  I know that this is what
transactions are for in a database, but what I want to avoid is two people
looking at the same unedited data and then editing it.  I guess what I
really want to is lock a database when I use starts editing the data.  The
issues are:
1) How to make sure someone exits the edit mode nicely? what happens if they
enter the edit page, do nothing and just close the browser, I don't what to
leave the table locked
2) if the table is locked I would still like to let users view the data in
real time, jut not edit it.

I've used a lock table for this in the past, but the issue that I've never
figured out is how to make sure someone still needs the lock.  Again number
(1) from above.

I hope that this makes sense, I'll be using sqlalchemy and postgres on the
back end

thanks for any and all advice
jose

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Locking a page?

2007-09-06 Thread Micah Elliott

On 2007-09-06 Jose Galvez wrote:

 I am looking for a way to lock a webpage so that only only
 one person at a time can edit database data.  Here is the
 scenario, I have a database with a limited number of users who
 have write access to the database, what I'd like to do is lock
 the editing page so that if one of my users is editing a page
 then the other users will not be able to edit the same
 page(data) at the same time.

You could look at the model the MoinMoin wiki uses (and probably
most wikis).  Basically, don't use the database to enforce the
edit locking, but rather set an application global lock and
timer on a page being edited that expires after some minutes
(and make the user aware of it).  Then when the time expires,
warn the editor that he just lost his lock and will lose his
changes permanently (or cause conflict) if he doesn't save/renew
ASAP.

Meanwhile, other would-be editors receive a page being edited,
try again in a few minutes, or deal with conflict message when
they try to edit the locked page.

As soon as the lock expires you have a race between editors to
try and obtain the lock.  You could make it more robust with some
rotation/priority protocol, but simple is probably better for
human page editing.

--
_ _ ___
|V|icah |- lliott
  
[EMAIL PROTECTED] http://MicahElliott.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Locking a page?

2007-09-06 Thread voltron

Hi Jose!

I am going to face the same problem with the application I am coding,
it is a sort of CMS. I have thought about adding a boolean field
called lock just as you have used in the past. When a user requests
a page to edit and the lock field is not set to true, she can edit the
page otherwise the user gets a javascript modal window using Jquery
and a plugin stating that the page can be viewed but not edited, the
textarea containing the editor is then set to editable = no. When
the user sets the page as published and not just saved the page, the
lock field is reset and her editor is set also to editable=no

This is theoretical, as I am still having problems with the Javascript
library I am using and Xinha( editor) and cant test at the moment.




On Sep 6, 10:07 pm, Jose Galvez [EMAIL PROTECTED] wrote:
 Hi all, I'm hunting for advice.  I am looking for a way to lock a webpage
 so that only only one person at a time can edit database data.  Here is the
 scenario, I have a database with a limited number of users who have write
 access to the database, what I'd like to do is lock the editing page so that
 if one of my users is editing a page then the other users will not be able
 to edit the same page(data) at the same time.  I know that this is what
 transactions are for in a database, but what I want to avoid is two people
 looking at the same unedited data and then editing it.  I guess what I
 really want to is lock a database when I use starts editing the data.  The
 issues are:
 1) How to make sure someone exits the edit mode nicely? what happens if they
 enter the edit page, do nothing and just close the browser, I don't what to
 leave the table locked
 2) if the table is locked I would still like to let users view the data in
 real time, jut not edit it.

 I've used a lock table for this in the past, but the issue that I've never
 figured out is how to make sure someone still needs the lock.  Again number
 (1) from above.

 I hope that this makes sense, I'll be using sqlalchemy and postgres on the
 back end

 thanks for any and all advice
 jose


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Locking a page?

2007-09-06 Thread voltron

This is the plugin I intend to use, it can effectively block user
input if needed with notification:

http://www.malsup.com/jquery/block/#page



On Sep 6, 10:39 pm, voltron [EMAIL PROTECTED] wrote:
 Hi Jose!

 I am going to face the same problem with the application I am coding,
 it is a sort of CMS. I have thought about adding a boolean field
 called lock just as you have used in the past. When a user requests
 a page to edit and the lock field is not set to true, she can edit the
 page otherwise the user gets a javascript modal window using Jquery
 and a plugin stating that the page can be viewed but not edited, the
 textarea containing the editor is then set to editable = no. When
 the user sets the page as published and not just saved the page, the
 lock field is reset and her editor is set also to editable=no

 This is theoretical, as I am still having problems with the Javascript
 library I am using and Xinha( editor) and cant test at the moment.

 On Sep 6, 10:07 pm, Jose Galvez [EMAIL PROTECTED] wrote:

  Hi all, I'm hunting for advice.  I am looking for a way to lock a webpage
  so that only only one person at a time can edit database data.  Here is the
  scenario, I have a database with a limited number of users who have write
  access to the database, what I'd like to do is lock the editing page so that
  if one of my users is editing a page then the other users will not be able
  to edit the same page(data) at the same time.  I know that this is what
  transactions are for in a database, but what I want to avoid is two people
  looking at the same unedited data and then editing it.  I guess what I
  really want to is lock a database when I use starts editing the data.  The
  issues are:
  1) How to make sure someone exits the edit mode nicely? what happens if they
  enter the edit page, do nothing and just close the browser, I don't what to
  leave the table locked
  2) if the table is locked I would still like to let users view the data in
  real time, jut not edit it.

  I've used a lock table for this in the past, but the issue that I've never
  figured out is how to make sure someone still needs the lock.  Again number
  (1) from above.

  I hope that this makes sense, I'll be using sqlalchemy and postgres on the
  back end

  thanks for any and all advice
  jose


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Locking a page?

2007-09-06 Thread David Turner

Don't do this.

There is no way to make 100% certain that you don't end up with stale
locks.  Sure, you can have an ajaxy thing that pings the server every
minute or so to say, I'm still editing this, but then the user goes
off to lunch and everyone is stuck until they get home.  Or a malicious
user can lock up all your pages forever.

If you do do it, make sure your locks are merely advisory (Warning:
Karl is editing this page right now.).  If your data is simple enough,
allow both edits and then merge changes programatically and let the user
resolve conflicts (like svn).  If it's too complex for that, then just
show the diff and let the user merge the changes.


On Thu, 2007-09-06 at 13:07 -0700, Jose Galvez wrote:
 Hi all, I'm hunting for advice.  I am looking for a way to lock a
 webpage so that only only one person at a time can edit database data.
 Here is the scenario, I have a database with a limited number of users
 who have write access to the database, what I'd like to do is lock the
 editing page so that if one of my users is editing a page then the
 other users will not be able to edit the same page(data) at the same
 time.  I know that this is what transactions are for in a database,
 but what I want to avoid is two people looking at the same unedited
 data and then editing it.  I guess what I really want to is lock a
 database when I use starts editing the data.  The issues are: 
 1) How to make sure someone exits the edit mode nicely? what happens
 if they enter the edit page, do nothing and just close the browser, I
 don't what to leave the table locked
 2) if the table is locked I would still like to let users view the
 data in real time, jut not edit it. 
 
 I've used a lock table for this in the past, but the issue that I've
 never figured out is how to make sure someone still needs the lock.
 Again number (1) from above.
 
 I hope that this makes sense, I'll be using sqlalchemy and postgres on
 the back end 
 
 thanks for any and all advice
 jose
 
  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Locking a page?

2007-09-06 Thread voltron

Hmm..then things would be harder than I expected,maybe just warning
the user as David suggested would be enough, when the users ignore the
warning, tough luck. I wonder how the other CMS apps take care of this
problem.

On Sep 7, 1:29 am, Jose Galvez [EMAIL PROTECTED] wrote:
 Hey voltron,

 I'll take a look at the library, it looks pretty cool.  David Turner,
 makes some really good points and is really the main thing that I''ve
 worried about.  My current site (the one that needs lots of work read I
 don't like the way I did it) uses a database to keep the locks, which I
 unlock when the user leaves the page (I'm using javascript thats
 pretty buggy and doesn't alway work) so I'm left doing occational
 cleanup on the Lock table.  Luckily for this project I have a pretty
 limited set of users so when I delete locks I'm pretty sure I'm not
 getting rid of an active lock, but I'm not really fond the the code.
 Like I said its pretty buggy.

 What I really need is someway to know when a user leaves the website -
 but I don't think thats really possible or reliable.
 Jose

 Jose

 voltron wrote:
  This is the plugin I intend to use, it can effectively block user
  input if needed with notification:

 http://www.malsup.com/jquery/block/#page

  On Sep 6, 10:39 pm, voltron [EMAIL PROTECTED] wrote:

  Hi Jose!

  I am going to face the same problem with the application I am coding,
  it is a sort of CMS. I have thought about adding a boolean field
  called lock just as you have used in the past. When a user requests
  a page to edit and the lock field is not set to true, she can edit the
  page otherwise the user gets a javascript modal window using Jquery
  and a plugin stating that the page can be viewed but not edited, the
  textarea containing the editor is then set to editable = no. When
  the user sets the page as published and not just saved the page, the
  lock field is reset and her editor is set also to editable=no

  This is theoretical, as I am still having problems with the Javascript
  library I am using and Xinha( editor) and cant test at the moment.

  On Sep 6, 10:07 pm, Jose Galvez [EMAIL PROTECTED] wrote:

  Hi all, I'm hunting for advice.  I am looking for a way to lock a 
  webpage
  so that only only one person at a time can edit database data.  Here is 
  the
  scenario, I have a database with a limited number of users who have write
  access to the database, what I'd like to do is lock the editing page so 
  that
  if one of my users is editing a page then the other users will not be able
  to edit the same page(data) at the same time.  I know that this is what
  transactions are for in a database, but what I want to avoid is two people
  looking at the same unedited data and then editing it.  I guess what I
  really want to is lock a database when I use starts editing the data.  The
  issues are:
  1) How to make sure someone exits the edit mode nicely? what happens if 
  they
  enter the edit page, do nothing and just close the browser, I don't what 
  to
  leave the table locked
  2) if the table is locked I would still like to let users view the data in
  real time, jut not edit it.

  I've used a lock table for this in the past, but the issue that I've 
  never
  figured out is how to make sure someone still needs the lock.  Again 
  number
  (1) from above.

  I hope that this makes sense, I'll be using sqlalchemy and postgres on the
  back end

  thanks for any and all advice
  jose


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Locking a page?

2007-09-06 Thread Jose Galvez
Hey voltron,

I'll take a look at the library, it looks pretty cool.  David Turner,
makes some really good points and is really the main thing that I''ve
worried about.  My current site (the one that needs lots of work read I
don't like the way I did it) uses a database to keep the locks, which I
unlock when the user leaves the page (I'm using javascript thats
pretty buggy and doesn't alway work) so I'm left doing occational
cleanup on the Lock table.  Luckily for this project I have a pretty
limited set of users so when I delete locks I'm pretty sure I'm not
getting rid of an active lock, but I'm not really fond the the code. 
Like I said its pretty buggy.

What I really need is someway to know when a user leaves the website -
but I don't think thats really possible or reliable.
Jose

Jose



voltron wrote:
 This is the plugin I intend to use, it can effectively block user
 input if needed with notification:

 http://www.malsup.com/jquery/block/#page



 On Sep 6, 10:39 pm, voltron [EMAIL PROTECTED] wrote:
   
 Hi Jose!

 I am going to face the same problem with the application I am coding,
 it is a sort of CMS. I have thought about adding a boolean field
 called lock just as you have used in the past. When a user requests
 a page to edit and the lock field is not set to true, she can edit the
 page otherwise the user gets a javascript modal window using Jquery
 and a plugin stating that the page can be viewed but not edited, the
 textarea containing the editor is then set to editable = no. When
 the user sets the page as published and not just saved the page, the
 lock field is reset and her editor is set also to editable=no

 This is theoretical, as I am still having problems with the Javascript
 library I am using and Xinha( editor) and cant test at the moment.

 On Sep 6, 10:07 pm, Jose Galvez [EMAIL PROTECTED] wrote:

 
 Hi all, I'm hunting for advice.  I am looking for a way to lock a webpage
 so that only only one person at a time can edit database data.  Here is the
 scenario, I have a database with a limited number of users who have write
 access to the database, what I'd like to do is lock the editing page so that
 if one of my users is editing a page then the other users will not be able
 to edit the same page(data) at the same time.  I know that this is what
 transactions are for in a database, but what I want to avoid is two people
 looking at the same unedited data and then editing it.  I guess what I
 really want to is lock a database when I use starts editing the data.  The
 issues are:
 1) How to make sure someone exits the edit mode nicely? what happens if they
 enter the edit page, do nothing and just close the browser, I don't what to
 leave the table locked
 2) if the table is locked I would still like to let users view the data in
 real time, jut not edit it.
   
 I've used a lock table for this in the past, but the issue that I've never
 figured out is how to make sure someone still needs the lock.  Again number
 (1) from above.
   
 I hope that this makes sense, I'll be using sqlalchemy and postgres on the
 back end
   
 thanks for any and all advice
 jose
   


 

   

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Locking a page?

2007-09-06 Thread Cliff Wells

On Thu, 2007-09-06 at 17:07 -0400, David Turner wrote:
 Don't do this.
 
 There is no way to make 100% certain that you don't end up with stale
 locks.  Sure, you can have an ajaxy thing that pings the server every
 minute or so to say, I'm still editing this, but then the user goes
 off to lunch and everyone is stuck until they get home.  

If you're using JS anyway, I'd use a combination of short-refresh
server-side locks (maybe 30s interval, with AJAX polling from the client
to keep the lock alive) and a keystroke client-side lock with a longer
(30m?) interval.  If the user doesn't interact with the form for 30m,
consider it unlocked and alert the user. 

 Or a malicious
 user can lock up all your pages forever.

Don't allow malicious users to edit your pages?

=)

Cliff



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---