I have a model that sets a default value using a function that is class
method on a model. Basically i have a model class representing a sales
order and the order number call the class method next_number from a
next_number table that has the next number for things like invoices, orders
... Prior to the upgrade everything worked without issue. After the upgrade
the update on the NextNumber class never gets committed. No errors or
anything it just silently falls into a SA black hole. Easy remendy, all i
did was remove the default setting it to u='' and then a call the same
function(without any changes to any other code) from with in the order
__init__.
Any thoughts? This isn't a show stopper but i would really like to know why
it fails so that I might not run into this thing down the road.
To upgrade i installed a fresh virtual env, the tg steps to install TG then
i pulled in my project using git clone, ran python setup.py develop to
bring my packages in.
globals.py
@classmethod
def next_number(cls,code):
current_number = DBSession.query(cls).filter(
func.lower(cls.code) == code.lower()
).with_lockmode('update').first()
saved_number = current_number.number
current_number.number += 1
return saved_number
m_op.py
def next_order_number():
result = "%010d" % m_gb.NextNumber.next_number('OP_ORDER')
log.debug("Result:%s" %result)
return result
class Order(DeclarativeBase,TimeUserMixin):
__tablename__ = 'orders'
id = Column(Integer, primary_key=True,autoincrement=True)
number =
Column(Unicode(15),unique=True,nullable=False,default=next_order_number)
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.