12
0

La til en funksjon som oppretter en midlertidig fil som man kan editere før man kjører commit

This commit is contained in:
2011-03-06 12:54:50 +00:00
parent 768a5309ec
commit 80c58558cd
2 changed files with 14 additions and 9 deletions
python

@ -48,8 +48,7 @@ class Book(models.Model):
def to_string(self, commit=False):
scratch = ''
if commit:
# generate commit string by sending self.to_dict to oysteini function
print self.to_dict()
# generate commit string by sending self.to_dict to fileformat function
print fileformat.write_action(self.to_dict())
else:
@ -63,8 +62,6 @@ class Book(models.Model):
scratch += format % (field[1], '')
authors = ', '.join(map(unicode, self.get_authors()))
scratch += format % ('Authors', authors)
# scratch += 'Authors'.ljust(15, ' ') + ':'
# scratch += authors.rjust(51, ' ')
return scratch
@ -163,7 +160,7 @@ class Person(models.Model):
def to_string(self, commit=False):
if commit:
#generate commit-string
print self.to_dict()
print fileformat.write_action(self.to_dict())
else:
format = '%-10s: %50s \n'
scratch = format % ('Name', ' '.join((self.first_name, self.last_name)))