Problem with BTreefolder, dictionaries and refresh/restart
Hello all, I have a strange Problem with a little python product I have written. It inherits from BTreeFolder and has an additional Attribute 'test' which is of the type dictionary. When I create a new instance of this Product, I can add a new key:value pair to the dictionary test. -> {'a':'1'} If I restart the server now or refresh my product, this dictionary entry still exists. But if I add a new key:value pair to test (or two, or three) and restart the server or refresh my product, all new entrys are gone. Only the first entry {'a':'1'} persits. If I try to change the first entry and restart or refresh, the changes to the first entry are gone too. 'test' seems to be static after the initial write access. Can anybody help me? Thanks in advance Sven Rudolph -- Sven Rudolph, Programmierer GermanMedicalServices.de GmbH Unter den Eichen 5, 65195 Wiesbaden Tel.: 06 11 / 97 46 25 2
this question has been answered quite often, for example here:: http://groups.yahoo.com/group/zope/message/92545 jens On Monday, July 8, 2002, at 02:34 , Sven Rudolph wrote:
Hello all,
I have a strange Problem with a little python product I have written. It inherits from BTreeFolder and has an additional Attribute 'test' which is of the type dictionary.
When I create a new instance of this Product, I can add a new key:value pair to the dictionary test. -> {'a':'1'} If I restart the server now or refresh my product, this dictionary entry still exists.
But if I add a new key:value pair to test (or two, or three) and restart the server or refresh my product, all new entrys are gone. Only the first entry {'a':'1'} persits. If I try to change the first entry and restart or refresh, the changes to the first entry are gone too.
'test' seems to be static after the initial write access. Can anybody help me?
Thanks in advance
Sven Rudolph
-- Sven Rudolph, Programmierer GermanMedicalServices.de GmbH Unter den Eichen 5, 65195 Wiesbaden Tel.: 06 11 / 97 46 25 2
I have a test site running which extracts records from an external database, displays them on a page, and allows updating of fields. So far so good. Now I need to provide a way for the user to upload a file, list what files have been uploaded, and download a selected file. These files need to be stored in the server's file system (Windows 2000) and each is related to a record in the database by a primary key value (which is an integer). My strategy is to create a sub directory in the file system for each record, as it is being created, which is the primary key value. All associated uploads will go into that sub directory. First question is how do I create a sub directory in the server's file system? I have looked at the localFS product intending to pull techniques from it but I've just gotten more confused as I look at it. Any pointers to specific examples which would be better to look at? Any HowTo's which cover this stuff?
On Mon, Jul 08, 2002 at 02:31:59PM -0400, Doug Chamberlin wrote:
First question is how do I create a sub directory in the server's file system?
Unless LocalFS allows for creation of new directories, this will almost definitely require an External Method. You should be able to do anything in an External Method that the Zope user on your system could do in a shell. As far as serving out the files, I think LocalFS is probably your best bet. ExtFile and ExtImage appear to be best suited for access to individual files, not a whole directory tree. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
Zope can not do that directly. I does not actually deal with the os-filesystem but mimmics its own which resides in ZODB. So if you want to deal with the "real" filesystem you have to write either an external method or a product. An external method would be something like this: def createdir(path): """ a method to create a directory """ import os try: os.mkdir(path) return 'went well' except: return 'failed' This method you put into a file in Zopes Extensions directory (eg as mkdir.py) from where you can access it as an external script. Robert ----- Original Message ----- From: "Doug Chamberlin" <DChamberlin@AndoverSoftware.com> To: <zope@zope.org> Sent: Monday, July 08, 2002 8:31 PM Subject: [Zope] Newbie question on uploading/downloading files
I have a test site running which extracts records from an external database, displays them on a page, and allows updating of fields. So far so good.
Now I need to provide a way for the user to upload a file, list what files have been uploaded, and download a selected file. These files need to be stored in the server's file system (Windows 2000) and each is related to a record in the database by a primary key value (which is an integer).
My strategy is to create a sub directory in the file system for each record, as it is being created, which is the primary key value. All associated uploads will go into that sub directory.
First question is how do I create a sub directory in the server's file system?
I have looked at the localFS product intending to pull techniques from it but I've just gotten more confused as I look at it. Any pointers to specific examples which would be better to look at? Any HowTo's which cover this stuff?
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hello Jens, thank you for your quick answer.
this question has been answered quite often, for example here:: http://groups.yahoo.com/group/zope/message/92545 Thanks for the advice. This works.
By the way. The Yahoo groups posting says, that persistance doesn't work with lists too. But I've never had persistance problems with lists or any other data type. Only with dictionarys... Anyway, now it works. Thanks again. Sven -- Sven Rudolph, Programmierer GermanMedicalServices.de GmbH Unter den Eichen 5, 65195 Wiesbaden Tel.: 06 11 / 97 46 25 2
participants (5)
-
Doug Chamberlin -
Jens Vagelpohl -
Mike Renfro -
Robert Rottermann -
Sven Rudolph