summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7cfecda)
raw | patch | inline | side by side (parent: 7cfecda)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 5 Feb 2010 05:10:52 +0000 (05:10 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 5 Feb 2010 05:10:52 +0000 (05:10 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4451 57a73879-2fb5-44c3-a270-3262357dd7e2
index d0eb1a9545150f64d20e59ca4c30206995c543f6..2ce4c4fd7635176c81ec907408200c1a0e77b8d5 100644 (file)
These operations trigger detectors and can be vetoed. Attempts
to modify the "creation" or "activity" properties cause a KeyError.
"""
+ if self.db.journaltag is None:
+ raise hyperdb.DatabaseError, _('Database open read-only')
self.fireAuditors('create', None, propvalues)
newid = self.create_inner(**propvalues)
self.fireReactors('create', newid, None)
These operations trigger detectors and can be vetoed. Attempts
to modify the "creation" or "activity" properties cause a KeyError.
"""
+ if self.db.journaltag is None:
+ raise hyperdb.DatabaseError, _('Database open read-only')
+
self.fireAuditors('set', nodeid, propvalues)
oldvalues = copy.deepcopy(self.db.getnode(self.classname, nodeid))
for name,prop in self.getprops(protected=0).items():
try:
for nodeid in self.getnodeids(cldb):
node = self.db.getnode(self.classname, nodeid, cldb)
+ print (nodeid, node, node[self.key], keyvalue)
if node.has_key(self.db.RETIRED_FLAG):
continue
if not node.has_key(self.key):
index 68da227e6781400d17cd87168b3c33ef05a55ea5..0e4d9f08050ab48facea8bcef8808c38614d7fde 100644 (file)
# file just ain't there
raise IOError('content file for %s not found'%filename)
+ def filesize(self, classname, nodeid, property=None, create=0):
+ filename = self.filename(classname, nodeid, property, create)
+ return os.path.getsize(filename)
+
def storefile(self, classname, nodeid, property, content):
"""Store the content of the file in the database. The property may be
None, in which case the filename does not indicate which property
diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py
index 80f4ee108eea9a71cc814822ccb18862c8115e05..5ba6b4512e03952a1b458f36b03053a01392dafc 100644 (file)
--- a/roundup/roundupdb.py
+++ b/roundup/roundupdb.py
if msgid :
for fileid in messages.get(msgid, 'files') :
# check the attachment size
- filename = self.db.filename('file', fileid, None)
- filesize = os.path.getsize(filename)
+ filesize = self.db.filesize('file', fileid, None)
if filesize <= self.db.config.NOSY_MAX_ATTACHMENT_SIZE:
message_files.append(fileid)
else:
diff --git a/test/db_test_base.py b/test/db_test_base.py
index 356fb7e56ef19e248b19a7898188394570dbf2cb..b245ef2a6161c5a31174ea4baf3b85f4f23dbcae 100644 (file)
--- a/test/db_test_base.py
+++ b/test/db_test_base.py
db.issue.nosymessage(i, m, {})
mail_msg = str(res["mail_msg"])
self.assertEqual(res["mail_to"], ["fred@example.com"])
- self.failUnless("From: admin" in mail_msg)
- self.failUnless("Subject: [issue1] spam" in mail_msg)
- self.failUnless("New submission from admin" in mail_msg)
- self.failUnless("one two" in mail_msg)
- self.failIf("File 'test1.txt' not attached" in mail_msg)
- self.failUnless(base64.encodestring("xxx").rstrip() in mail_msg)
- self.failUnless("File 'test2.txt' not attached" in mail_msg)
- self.failIf(base64.encodestring("yyy").rstrip() in mail_msg)
+ self.assert_("From: admin" in mail_msg)
+ self.assert_("Subject: [issue1] spam" in mail_msg)
+ self.assert_("New submission from admin" in mail_msg)
+ self.assert_("one two" in mail_msg)
+ self.assert_("File 'test1.txt' not attached" not in mail_msg)
+ self.assert_(base64.encodestring("xxx").rstrip() in mail_msg)
+ self.assert_("File 'test2.txt' not attached" in mail_msg)
+ self.assert_(base64.encodestring("yyy").rstrip() not in mail_msg)
finally :
Mailer.smtp_send = backup
diff --git a/test/memorydb.py b/test/memorydb.py
index ce10086ca7ea953b05bdc80879d0b72e7408d346..ea76be7dd458e5d735766245ec452615430591d5 100644 (file)
--- a/test/memorydb.py
+++ b/test/memorydb.py
shutil.copyfile(__file__, __file__+'.dummy')
return __file__+'.dummy'
+ def filesize(self, classname, nodeid, property=None, create=0):
+ return len(self.getnode(classname, nodeid)[property or 'content'])
+
def post_init(self):
pass
def newid(self, classname):
self.ids[classname] += 1
return str(self.ids[classname])
+ def setid(self, classname, id):
+ self.ids[classname] = id
#
# Nodes
def getnode(self, classname, nodeid, db=None):
if db is not None:
return db[nodeid]
- return self.getclassdb(classname)[nodeid]
+ d = self.getclassdb(classname)
+ if nodeid not in d:
+ raise IndexError(nodeid)
+ return d[nodeid]
def destroynode(self, classname, nodeid):
del self.getclassdb(classname)[nodeid]
class Class(back_anydbm.Class):
def getnodeids(self, db=None, retired=None):
- return self.db.getclassdb(self.classname).keys()
+ d = self.db.getclassdb(self.classname)
+ if retired is None:
+ return d.keys()
+ return [k for k in d if d[k].get(self.db.RETIRED_FLAG, False) == retired]
class FileClass(back_anydbm.Class):
def __init__(self, db, classname, **properties):