Hey folks,
I have a model that is used to create a config file on the system, it
works ok except for one field.
Within my Repo model I have a M2M relationship with
InstalledExtentions like this:
class Repo(models.Model):
"""A repo represents a physical repository on the hg system path"""
....
active_extentions=models.ManyToManyField(InstalledExtentions)
Then within the signal to write the file, I have this:
def create_hgrc(sender, instance, signal, *args, **kwargs):
"""This function outputs a hgrc file within a repo's .hg
directory, for use with hgweb"""
...
hgrc = open(directory + '/.hg/hgrc', 'w')
hgrc.write('[paths]\n')
hgrc.write('default = %s\n\n' % instance.repo_url)
hgrc.write('[web]\n')
hgrc.write('style = %s\n' % s.short_name)
hgrc.write('description = %s\n' % instance.repo_description)
hgrc.write('contact = %s <%s>\n' % (c.username, c.email))
a = 'allow_archive = '
if instance.offer_zip:
a += 'zip '
if instance.offer_tar:
a += 'gz '
if instance.offer_bz2:
a += 'bz2'
hgrc.write(a + '\n\n')
hgrc.write('[extentions]')
# TODO: This doesn't seem to be working :/
for e in instance.active_extentions.all():
hgrc.write('hgext.%s = \n' % e)
hgrc.close()
As you can see I've commented where the code is not working. When i
do repo.active_extentions.all() in the shell it works fine and returns
them. Even if e doesn't have the right data at the moment it should
still write each line for each active extention.
Can anyone help?
--
Tane Piper
Blog - http://digitalspaghetti.me.uk
Wii: 4734 3486 7149 1830
This email is: [ ] blogable [ x ] ask first [ ] private
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---