Projects
/
mdb-ng
Archived
4
0
Fork 0

Now how a working load function. A bit hackish since it now chdirs into

the database directory.
This commit is contained in:
Øyvind Grønnesby 2005-05-27 15:13:16 +00:00
parent 782191573e
commit 6dfee80fff
1 changed files with 6 additions and 5 deletions

View File

@ -100,12 +100,13 @@ class PVVDB:
def load(self, username, lock=False): def load(self, username, lock=False):
# Read the record from the database. Will do an automatic lock # Read the record from the database. Will do an automatic lock
# if `lock' is True. # if `lock' is True.
rv = self.rcs.checkout( cwd = os.getcwd()
self.__filename(username), lock) os.chdir(self.base)
userfile = file(self.__filename(username)) rv = self.rcs.checkout(username + ",v")
userfile = file(username)
os.chdir(cwd)
member = {} member = {}
for line in userfile: for line in userfile:
print line
key, value = line.strip().split(": ", 1) key, value = line.strip().split(": ", 1)
if not key in self.format: if not key in self.format:
raise PVVDBError, "%s not a legal attribute." % `key` raise PVVDBError, "%s not a legal attribute." % `key`
@ -121,7 +122,7 @@ class PVVDB:
else: else:
# we should not be here # we should not be here
raise PVVDBError, "%s not legal datatype." % `self.format[key]` raise PVVDBError, "%s not legal datatype." % `self.format[key]`
member[key] = value member[key] = v
return PVVMember(member, self) return PVVMember(member, self)
def save(self, username, comment="", lock=False): def save(self, username, comment="", lock=False):