summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 00d1b4e)
raw | patch | inline | side by side (parent: 00d1b4e)
author | rochecompaan <rochecompaan@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 21 Jan 2002 16:33:20 +0000 (16:33 +0000) | ||
committer | rochecompaan <rochecompaan@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 21 Jan 2002 16:33:20 +0000 (16:33 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@574 57a73879-2fb5-44c3-a270-3262357dd7e2
diff --git a/CHANGES.txt b/CHANGES.txt
index 67d1cadd746743784c911ddcb792395e9f7c1eb2..10091cff7b4249920199493dc843472ca68ff8a5 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
for arguments are specified for link or mutlilink properties.
. modified unit test to check nosy and assignedto when specified as
arguments
+ . you can now use the roundup-admin tool pack the database
Fixed:
. handle attachments with no name (eg tnef)
diff --git a/roundup/admin.py b/roundup/admin.py
index 34ec404e672527ce05817fbc137fdeceb4ad1b43..679315c29d9898709024efcad0400a4a14496278 100644 (file)
--- a/roundup/admin.py
+++ b/roundup/admin.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: admin.py,v 1.4 2002-01-14 06:51:09 richard Exp $
+# $Id: admin.py,v 1.5 2002-01-21 16:33:19 rochecompaan Exp $
import sys, os, getpass, getopt, re, UserDict, shlex
try:
apply(cl.create, (), d)
return 0
+ def do_pack(self, args):
+ '''Usage: pack period | date
+
+Remove journal entries older than a period of time specified or
+before a certain date.
+
+A period is specified using the suffixes "y", "m", and "d". The
+suffix "w" (for "week") means 7 days.
+
+ "3y" means three years
+ "2y 1m" means two years and one month
+ "1m 25d" means one month and 25 days
+ "2w 3d" means two weeks and three days
+
+Date format is "YYYY-MM-DD" eg:
+ 2001-01-01
+
+ '''
+ if len(args) <> 1:
+ raise UsageError, _('Not enough arguments supplied')
+
+ # are we dealing with a period or a date
+ value = args[0]
+ date_re = re.compile(r'''
+ (?P<date>\d\d\d\d-\d\d?-\d\d?)? # yyyy-mm-dd
+ (?P<period>(\d+y\s*)?(\d+m\s*)?(\d+d\s*)?)?
+ ''', re.VERBOSE)
+ m = date_re.match(value)
+ if not m:
+ raise ValueError, _('Invalid format')
+ m = m.groupdict()
+ if m['period']:
+ # TODO: need to fix date module. one should be able to say
+ # pack_before = date.Date(". - %s"%value)
+ pack_before = date.Date(".") + date.Interval("- %s"%value)
+ elif m['date']:
+ pack_before = date.Date(value)
+ self.db.pack(pack_before)
+ return 0
+
def run_command(self, args):
'''Run a single command
'''
#
# $Log: not supported by cvs2svn $
+# Revision 1.4 2002/01/14 06:51:09 richard
+# . #503164 ] create and passwords
+#
# Revision 1.3 2002/01/08 05:26:32 rochecompaan
# Missing "self" in props_from_args
#
index 6b5bb2e836261d2b865838a61b0866fb91ea2085..bfdc14217429c520c8c5625b95e14ce54f6b7cef 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_anydbm.py,v 1.23 2002-01-18 04:32:04 richard Exp $
+#$Id: back_anydbm.py,v 1.24 2002-01-21 16:33:20 rochecompaan Exp $
'''
This module defines a backend that saves the hyperdatabase in a database
chosen by anydbm. It is guaranteed to always be available in python
res.append((nodeid, date_obj, self.journaltag, action, params))
return res
+ def pack(self, pack_before):
+ ''' delete all journal entries before 'pack_before' '''
+ if DEBUG:
+ print 'packjournal', (self, pack_before)
+
+ pack_before = pack_before.get_tuple()
+
+ classes = self.getclasses()
+
+ # TODO: factor this out to method - we're already doing it in
+ # _opendb.
+ db_type = ''
+ path = os.path.join(os.getcwd(), self.dir, classes[0])
+ if os.path.exists(path):
+ db_type = whichdb.whichdb(path)
+ if not db_type:
+ raise hyperdb.DatabaseError, "Couldn't identify database type"
+ elif os.path.exists(path+'.db'):
+ db_type = 'dbm'
+
+ for classname in classes:
+ db_name = 'journals.%s'%classname
+ db = self._opendb(db_name, 'w')
+
+ for key in db.keys():
+ journal = marshal.loads(db[key])
+ l = []
+ for entry in journal:
+ (nodeid, date_stamp, self.journaltag, action,
+ params) = entry
+ if date_stamp > pack_before or action == 'create':
+ l.append(entry)
+ db[key] = marshal.dumps(l)
+ if db_type == 'gdbm':
+ db.reorganize()
+ db.close()
+
#
# Basic transaction support
#
#$Log: not supported by cvs2svn $
+#Revision 1.23 2002/01/18 04:32:04 richard
+#Rollback was breaking because a message hadn't actually been written to the file. Needs
+#more investigation.
+#
#Revision 1.22 2002/01/14 02:20:15 richard
# . changed all config accesses so they access either the instance or the
# config attriubute on the db. This means that all config is obtained from
diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py
index 9a2406aa2b8e7a8d892e9845503453e258f06621..8a12af13add2e30984844e49a1cfd9499ad50992 100644 (file)
--- a/roundup/hyperdb.py
+++ b/roundup/hyperdb.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: hyperdb.py,v 1.51 2002-01-21 03:01:29 richard Exp $
+# $Id: hyperdb.py,v 1.52 2002-01-21 16:33:19 rochecompaan Exp $
__doc__ = """
Hyperdatabase implementation, especially field types.
'''
raise NotImplementedError
+ def pack(self, pack_before):
+ ''' pack the database
+ '''
+ raise NotImplementedError
+
def commit(self):
''' Commit the current transactions.
#
# $Log: not supported by cvs2svn $
+# Revision 1.51 2002/01/21 03:01:29 richard
+# brief docco on the do_journal argument
+#
# Revision 1.50 2002/01/19 13:16:04 rochecompaan
# Journal entries for link and multilink properties can now be switched on
# or off.
diff --git a/test/test_db.py b/test/test_db.py
index 9632d365a6dfd036e9df619434ffa0dcfbc4a6cb..1412b73dc5f5076b825f834b33ba4f897790ad34 100644 (file)
--- a/test/test_db.py
+++ b/test/test_db.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_db.py,v 1.15 2002-01-19 13:16:04 rochecompaan Exp $
+# $Id: test_db.py,v 1.16 2002-01-21 16:33:20 rochecompaan Exp $
import unittest, os, shutil
self.assertEqual('unlink', action)
self.assertEqual(('issue', '1', 'fixer'), params)
+ def testPack(self):
+ self.db.issue.create(title="spam", status='1')
+ self.db.issue.set('1', status='2')
+ self.db.commit()
+
+ pack_before = date.Date(". + 1d")
+ self.db.pack(pack_before)
+ journal = self.db.getjournal('issue', '1')
+ self.assertEqual(1, len(journal))
+
def testRetire(self):
pass
#
# $Log: not supported by cvs2svn $
+# Revision 1.15 2002/01/19 13:16:04 rochecompaan
+# Journal entries for link and multilink properties can now be switched on
+# or off.
+#
# Revision 1.14 2002/01/16 07:02:57 richard
# . lots of date/interval related changes:
# - more relaxed date format for input