So the only difference between this and FSCounter is that you implemented the locking I didn't. To cut a long story short the reason i didnt implement locking was Python on Windows doesnt have fnctl (http://velocity.activestate.com/docs/ActivePython/lib/module-fcntl.html), Perl does though.... If anyone knows of a module to lock and unlock cross platform I would appreciate it. Zope by the way locks in /lib/python/ZODB/lock_file.py, but there is no unlock. Maybe if we added an unlock in here this would provide a global lock and unlock function. I released FSPoll recently and was going to combine the two into one FSCountThing with FSPoll and FSCounter subclassing of it, so maybe we could co-operate on ThreadSafeCounter and FSCounter? Cheers. -- Andy McKay.
[Andy McKay] | I released FSPoll recently and was going to combine the two into one | FSCountThing with FSPoll and FSCounter subclassing of it, so maybe we could | co-operate on ThreadSafeCounter and FSCounter? The ideal solution would be to use an object that lives in the ZODB, I wonder if there is a way to keep the 'object history' empty? That is, keeping the counter 'packed' while retaining 'object history' information on all other objects. In any case, I think it's possible to implement a file-locking module, that locks the file using a .lock extension (writing the pid of the locking process to that file) or something like that.. Which should work on Linux and Windows (and most other OS') Should I toss up a Wiki? Cheers, Morten
[Morten W. Petersen] | The ideal solution would be to use an object that lives in the ZODB, | I wonder if there is a way to keep the 'object history' empty? That | is, keeping the counter 'packed' while retaining 'object history' | information on all other objects. I'm no ZODB expert, but I think the short story is that you can't have this across several threads -- because you would have to use _v_ attribs. And what good is a ThreadSafeCounter if it's not threadsafe? By the way, the reasons for this to be better as a ZODB object is that you wouldn't have to worry about which filesystem the server runs, and if there is serveral servers? If you have the resources, a really cool thing would be to set up a Zope box running a counter and an XML-RPC script in the other end. That wouldn't be a problem making safe. You do have other stuff to consider then, though. I like XML-RPC.
| The ideal solution would be to use an object that lives in the ZODB, | I wonder if there is a way to keep the 'object history' empty? That | is, keeping the counter 'packed' while retaining 'object history' | information on all other objects.
That would work, however I just dont think that fits neatly into the ZODB in any way since all objects are appended.
I'm no ZODB expert, but I think the short story is that you can't have this across several threads -- because you would have to use _v_ attribs. And what good is a ThreadSafeCounter if it's not threadsafe?
Well it would be threadsafe since the object cannot be written too by multiple threads as discussed earlier it will keep try 3 times and then fail. To me the ideal answer is a simple FileSystem product that allows you to mount a file system inside the ZODB. This would implrement locking and be hence be thread safe. Its a real science project. This would also have to be ZEO friendly, but to be honest for my use and most other peoples, this isnt a huge concern.
I like XML-RPC.
Me too but its sloooow. -- Andy McKay.
Andy McKay wrote:
| The ideal solution would be to use an object that lives in the ZODB, | I wonder if there is a way to keep the 'object history' empty? That | is, keeping the counter 'packed' while retaining 'object history' | information on all other objects.
That would work, however I just dont think that fits neatly into the ZODB in any way since all objects are appended.
Don't get ZODB confused with FileStorage. What you say is true of FileStorage, not of ZODB.
I'm no ZODB expert, but I think the short story is that you can't have this across several threads -- because you would have to use _v_ attribs. And what good is a ThreadSafeCounter if it's not threadsafe?
Well it would be threadsafe since the object cannot be written too by multiple threads as discussed earlier it will keep try 3 times and then fail. To me the ideal answer is a simple FileSystem product that allows you to mount a file system inside the ZODB. This would implrement locking and be hence be thread safe. Its a real science project. This would also have to be ZEO friendly, but to be honest for my use and most other peoples, this isnt a huge concern.
A simpler solution is to use a mounted storage that doesn't do undo, and stores changes in place. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
A simpler solution is to use a mounted storage that doesn't do undo, and stores changes in place.
You are the second person to answer with that. Would anyone care to give a quick how-to on how to mount a non-undoing storage, such as FileStorage since this doesnt seem immediately obvious to me. -- Andy McKay.
-- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Andy McKay wrote:
A simpler solution is to use a mounted storage that doesn't do undo, and stores changes in place.
You are the second person to answer with that. Would anyone care to give a quick how-to on how to mount a non-undoing storage, such as FileStorage
FileStorage is what the standard Data.fs is, and it supports undo.
since this doesnt seem immediately obvious to me.
Take a look at ExternalMount, and at what's used in the CoreSessionTracking product. I can't find a URL for ExternalMount at the moment. I'm using it though, so it *definitely* exists! Also, see lib/python/ZODB/dbmStorage.py """Very Simple dbm-based ZODB storage This storage provides for use of dbm files as storages that don't support versions or Undo. This may be useful when implementing objects like hit counters that don't need or want to participate in undo or versions. """ -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Would anyone volunteer to write a mounting HOWTO? This is a FAQ. ----- Original Message ----- From: "Steve Alexander" <steve@cat-box.net> To: "Andy McKay" <andym@ActiveState.com> Cc: <zope-dev@zope.org> Sent: Tuesday, February 13, 2001 1:30 PM Subject: Re: [Zope-dev] Re: ThreadSafeCounter
Andy McKay wrote:
A simpler solution is to use a mounted storage that doesn't do undo, and stores changes in place.
You are the second person to answer with that. Would anyone care to give a quick how-to on how to mount a non-undoing storage, such as FileStorage
FileStorage is what the standard Data.fs is, and it supports undo.
since this doesnt seem immediately obvious to me.
Take a look at ExternalMount, and at what's used in the CoreSessionTracking product.
I can't find a URL for ExternalMount at the moment. I'm using it though, so it *definitely* exists!
Also, see lib/python/ZODB/dbmStorage.py
"""Very Simple dbm-based ZODB storage
This storage provides for use of dbm files as storages that don't support versions or Undo. This may be useful when implementing objects like hit counters that don't need or want to participate in undo or versions. """
-- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Would anyone volunteer to write a mounting HOWTO? This is a FAQ.
The ExternalMount product is kind of self instructing, but a general Mounting HOWTO would be a good thing.
FileStorage is what the standard Data.fs is, and it supports undo.
Just one thing, ExternalMount product uses FileStorage but it doesn't seem to support undos (not for me anyway)? Johan Carlsson <From the ExternalMount product> Create an external method that opens a storage and returns a ZODB.DB object. Enter the module and function name below, along with the path to traverse within the database to reach the object to be mounted. An example external method: import ZODB from ZODB.FileStorage import FileStorage def createDB(): return ZODB.DB(FileStorage('/usr/local/zodbs/db1.fs')) <From the ExternalMount product>
Andy McKay wrote:
A simpler solution is to use a mounted storage that doesn't do undo, and stores changes in place.
You are the second person to answer with that. Would anyone care to give a quick how-to on how to mount a non-undoing storage, such as
FileStorage is what the standard Data.fs is, and it supports undo.
since this doesnt seem immediately obvious to me.
Take a look at ExternalMount, and at what's used in the CoreSessionTracking product.
I can't find a URL for ExternalMount at the moment. I'm using it though, so it *definitely* exists!
Also, see lib/python/ZODB/dbmStorage.py
"""Very Simple dbm-based ZODB storage
This storage provides for use of dbm files as storages that don't support versions or Undo. This may be useful when implementing objects like hit counters that don't need or want to participate in undo or versions. """
-- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Shane's ExternalMount product is here: http://www.zope.org/Members/hathawsh/ExternalMount However, I couldn't find it from searching on zope.org, and it isn't listed on Shane's zope.org page. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Steve Alexander wrote:
Shane's ExternalMount product is here:
http://www.zope.org/Members/hathawsh/ExternalMount
However, I couldn't find it from searching on zope.org, and it isn't listed on Shane's zope.org page.
Oops, I forgot to get it cataloged. Shane
participants (7)
-
Andy McKay -
Chris McDonough -
Erik Enge -
Johan Carlsson -
morten@esol.no -
Shane Hathaway -
Steve Alexander