Roundup Tracker - Issues

Issue 914062

classification
Allow update of file-backed
Type: rfe Severity: normal
Components: Database Versions:
process
Status: closed fixed
:
: richard : jkew, richard
Priority: normal :

Created on 2004-03-11 11:40 by jkew, last changed 2004-03-19 04:50 by richard.

Messages
msg3296 Author: [hidden] (jkew) Date: 2004-03-11 11:40
I'd like to be able to write admin scripts which rewrite 
msg content -- for example, to fixup "issue 23" 
to "issue23", or to fix up "http://oldserver/stuff" 
to "http://newserver/stuff".

I can do this by grovelling around in the db/files/msg 
directory of the tracker, but this feels quite dirty -- it'd 
feel cleaner to be able to do it through the hyperdb API.

However, while I can get msg content:

>>> db.msg.get("216", "content")
"old"

I can't set msg content:

>>> db.msg.set("216", content="new")
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python23\Lib\site-
packages\roundup\backends\rdbms_common.py", line 
1308, in set
    raise KeyError, '"%s" has no property named "%s"'%(
KeyError: '"msg" has no property named "content"'

In the RDBMS backends, the "content" property is 
special-cased on create and get to read/write from file; 
but it's not special-cased on set. (I think this is also the 
case in the other backends.)

Can go lower-level to get the content directly from the 
file, although this does make an assumption on how files 
are named:

>>> db.getfile("msg", "216", "")
"old"

and can attempt to change the content:

>> db.storefile("msg", "216", "", "new")

but this fails on commit:

>>> db.commit()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python23\Lib\site-
packages\roundup\backends\rdbms_common.py", line 
813, in commit
    reindex[method(*args)] = 1
  File "C:\Python23\Lib\site-
packages\roundup\backends\blobfiles.py", line 115, in 
doStoreFile
    os.rename(name+".tmp", name)
OSError: [Errno 17] File exists
msg3297 Author: [hidden] (jkew) Date: 2004-03-11 20:23
Logged In: YES 
user_id=598066

...although the second traceback will only occur on Windows, 
where os.rename fails if the destination already exists. On 
Unix, os.rename silently replaces the destination.
msg3298 Author: [hidden] (richard) Date: 2004-03-11 21:05
Logged In: YES 
user_id=6405

Yes, set() should work for the special "content" property. 
msg3299 Author: [hidden] (richard) Date: 2004-03-19 04:50
Logged In: YES 
user_id=6405

I've implemented a fix for this in CVS HEAD (too much needed changing 
for it to go into 0.6, sorry) 
 
0.7 is close. Very close... 
History
Date User Action Args
2004-03-11 11:40:20jkewcreate