[sqlalchemy] Re: Creating a custom type

2009-01-01 Thread Kless
I've been trying create the extension. Here is the code with a test: http://paste.pocoo.org/show/97502/ - Extension http://paste.pocoo.org/show/97503/ - Test I need help to solve this little issue: entity._descriptor.add_mapper_extension(BcryptMapperExtension()) AttributeError: 'str'

[sqlalchemy] Re: Creating a custom type

2009-01-01 Thread Michael Bayer
mapper extensions are established during the mapper() phase: mapper(someclass, sometable, extension=BycryptMapperExtension()) On Jan 1, 2009, at 1:35 PM, Kless wrote: I've been trying create the extension. Here is the code with a test: http://paste.pocoo.org/show/97502/ - Extension

[sqlalchemy] Re: Creating a custom type

2009-01-01 Thread Kless
It's being passed from the IsBcrypt constructor, so: entity._descriptor.add_mapper_extension(BcryptMapperExtension()) On 1 ene, 19:48, Michael Bayer mike...@zzzcomputing.com wrote: mapper extensions are established during the mapper() phase: mapper(someclass, sometable,

[sqlalchemy] Re: Creating a custom type

2009-01-01 Thread Kless
I just see that will be by a problem of change in API AttributeError: 'str' object has no attribute '_descriptor' Kless ha escrito: It's being passed from the IsBcrypt constructor, so: entity._descriptor.add_mapper_extension(BcryptMapperExtension()) On 1 ene, 19:48, Michael Bayer

[sqlalchemy] Re: Creating a custom type

2009-01-01 Thread Jonathan LaCour
Kless wrote: I just see that will be by a problem of change in API AttributeError: 'str' object has no attribute '_descriptor' As I indicated to you over on the Elixir list, you seem to have used the Elixir encryption extension as a starting point. The _descriptor and the concept of an

[sqlalchemy] Re: Creating a custom type

2009-01-01 Thread Kless
Thanks. This was your message on the Elixir list: It looks to me like you are using SQLAlchemy without Elixir, and therefore this isn't the proper place to be asking this question. You should ask over on the SQLAlchemy mailing list. If you would like help creating an elixir extension, I can

[sqlalchemy] Re: Creating a custom type

2008-12-22 Thread Kless
Thank you. Your aid is incalculable as always. I'll use a descriptor for this case as you well advise. On 22 dic, 03:40, Michael Bayer mike...@zzzcomputing.com wrote: oh, yeah for that recipe you'd have to use a flag on the mapper()   called batch=False.    But don't use that, its inefficient.

[sqlalchemy] Re: Creating a custom type

2008-12-22 Thread Kless
Although it's necessary to consider that continues being necessary a custom type to add a new argument (in this case is 'cost'). And I prefer a custom type before that a subclass of Column for this one. Now well, to get the another argument which is at instance-level surely will be better make

[sqlalchemy] Re: Creating a custom type

2008-12-21 Thread Michael Bayer
On Dec 21, 2008, at 6:53 AM, Kless wrote: I'm trying to build a custom type [1] to manage the bcrypt hashes [2]. --- from bcrypt_wrap import password from sqlalchemy import types class Bcrypt(types.TypeDecorator): Stores a bcrypt hash of a password. impl = types.String

[sqlalchemy] Re: Creating a custom type

2008-12-21 Thread Kless
Thank you for detailed answer. Here are any thoughts: 1) The before_insert was being omitted while I was inserting records using an insert statement --that's logical because it was bypassing the ORM--. 2) It's necessary to use *session.commit()* after of each record because else it will have

[sqlalchemy] Re: Creating a custom type

2008-12-21 Thread Michael Bayer
oh, yeah for that recipe you'd have to use a flag on the mapper() called batch=False.But don't use that, its inefficient. So you can also create your type to detect a special value from the mapper extension: def before_insert(self, ): instance.password = (instance.password,