On 23/11/2010 12:03, Michael McAndrew wrote:
I am now getting the following error - any ideas?
Yes, but it might be fruitful for you to try to work it out :-) It's an
issue caused by the fact I always had current generations in my mapit
from the start, so didn't notice this.
Step by step help:
1. Taking the last bit of the traceback:
File
"/home/ubuntu/mapit/pylib/mapit/areas/management/commands/import_boundary_line.py",
line 110, in handle_label
if m.generation_high and m.generation_high.id < current_generation.id:
AttributeError: 'int' object has no attribute 'id'
So one of m.generation_high or current_generation is an 'int' (integer)
rather than an object (that would have an 'id' attribute).
2. m.generation_high must be an object, as it's either returned from a
current Area object or is part of a new Area object where it's set to
new_generation - which has a check that it's okay at line 35. So
current_generation must be an integer and the source of the problem (you
could also have checked this by adding some print statements to the file
and rerunning it, that's my usual method :) ).
3. current_generation is set by Generation.objects.current() which is in
area/models.py - and we see that if there is no current generation, this
function does indeed return the integer 0.
4. Ignoring the fact it should probably return None, as that might well
have knock-on effects, we can conclude that if you don't have a current
generation, you definitely don't want the generation test of line 110 to
fail - it doesn't make sense to test against something that doesn't
exist (it's a test to check that it's not about to make some old
out-of-generation area current again, which you never want to happen).
5. So line 110 should be changed to
if m.generation_high and current_generation and m.generation_high.id <
current_generation.id:
ie. check that current_generation exists before doing the comparison check.
Feel free to apply that and submit a patch - if you'd cloned the
repository on github to your own account, you could patch and push there
and then I could pull it. :)
ATB,
Matthew
_______________________________________________
Mailing list [email protected]
Archive, settings, or unsubscribe:
https://secure.mysociety.org/admin/lists/mailman/listinfo/developers-public