Thanks for the pointers, Mathew.

I had some suspicions developing along those lines.  Had printed the
statements, etc.  Guess I just needed confirmation that it was a bug and not
something stupid I was doing - hard for me to make that call being
unfamiliar with the data and code

anyway, encountered another little bug, dug out my python in a nutshell,
cloned your repo.

Exception: ONS code 999999999 is used for Chiltern Valley ED and Buckingham
> North ED


assuming this can be fixed with


> ons_code = feat['CODE'].value if not
> feat['CODE'].value.startswith('999999') else None
>

on line 47.

Will push to https://github.com/michaelmcandrew/mapit there once i have
mapit it up and running.

will also have an ec2 image if that is of use to people?


On Tue, Nov 23, 2010 at 12:19 PM, Matthew Somerville
<[email protected]>wrote:

> 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
>



-- 
Michael McAndrew
07817 802299 (mobile)

Third Sector Design Ltd.
http://thirdsectordesign.org

For support, email [email protected]
_______________________________________________
Mailing list [email protected]
Archive, settings, or unsubscribe:
https://secure.mysociety.org/admin/lists/mailman/listinfo/developers-public

Reply via email to