python - Auto-incrementing attribute with custom logic in SQLAlchemy -


I have a simple "invoice" class with the "number" attribute, which is assigned when the user saves a Invoice Some obstacles are:

1) The application is a (thin) client-server one, so whatever the number that determines should be seen for the collision - 2) There is also a "version" attribute in the invoice, So I can not use a simple DBMS-level automating field

I'm trying to create it using a custom type, which is saved every time an invoice is saved. Whenever process_bind_param is not called any value, then it will call any type of singleton to determine the number and avoid collision. Is this a decent solution? Anyway, I am having a problem. This is my custom type:

  class autoimmunity (type type decokerter): impl = types.Unicode def copy (self): return automation ( Def defragment_bind_param (self, value, bid): if not value: # Must be found next autoincrement value value = "1" # Exam value :) Return value  

My problem is just that when I left an invoice and auto increment set the value as "1" for my number, invoice Eg not are updated with the new number .. Is it required? Am I forgetting something?

Edit: Michael Bayer told me that this is the behavior, it is very much thanks for you!

(SQLS 0.5.3 on Python 2.6, PostGraceQL 8.3) expected, because TypeDecorators do not deal with default values.

Is there no special reason to just type the default = parameter in its column definition Use? (This can be a standard dragon).

  def generated_invoice_number (): # Special argument invoice to generate a unique invoice number class (DeclarativeBase): __tablename__ = 'invoice' number = column (integer, exclusive = true, default = generation_invoices_number ) ...  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -