Hello,

Simple question, I have a column "score" in a table which is defined as 
a property in my model :

@property
def score(self):
    weights = dict(high=3, medium=2, likely=2, low=1, unlikely=1)

    score = weights.get(self.dispersion_potential, 0)
    score += weights.get(self.natural_habitats, 0)
    score += max((weights.get(x, 0) for x in self.impact_species))
    score += max((weights.get(x, 0) for x in self.impact_ecosystems))

    return score

but it seems that SQLAlchemy can't see it, I have an error when I .flush() :
SQLError: (IntegrityError) null value in column "score" violates 
not-null constraint

I know that I could use a mapper extension for this (with before_insert, 
before_update, etc) but could it not be possible to do it with my 
@property ?

Thanks,
Julien

-- 
Julien Cigar
Belgian Biodiversity Platform
http://www.biodiversity.be
Université Libre de Bruxelles (ULB)
Campus de la Plaine CP 257
Bâtiment NO, Bureau 4 N4 115C (Niveau 4)
Boulevard du Triomphe, entrée ULB 2
B-1050 Bruxelles
office: [EMAIL PROTECTED]
home: [EMAIL PROTECTED]
biobel reference: http://biobel.biodiversity.be/biobel/person/show/471


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to