I think the keyword-enabled __init__() method created by assign_class () should be created within the sqlalchemy assign_mapper() method, if the given class doenst have an __init__() method defined already. that way code like this would work, if no other __init__() method was already created.

On Jan 15, 2006, at 10:23 PM, Robert Leftwich wrote:

Murat Özsöyler wrote:
The following code inserts a row with the values: ID=1, NAME=u''.
<code>
m = trial2.Master(NAME="Deneme")
trial2.objectstore.commit()
</code>
If I comment out the default parameter for NAME column then I get this exception:

Not sure where the 'trial2' comes from, but you need to set NAME to be something outside of the constructor, i.e

  m = trial2.Master()
  m.NAME="Deneme"
  trial2.objectstore.commit()

or add a constructor to your Master class that knows what to do with NAME, e.g.

  class Master:
    def __init__(self,  name=None...)
      self.NAME=name
      ...

assign_mapper() adds a mapper to your class (and a few functions, such as get(), select_by(), etc but it doesn't add an __init__() that automatically assigns any keyword args to properties. See an earlier email thread titled 'easy create user-defined class' which has some code for this sort of auto-assignment.

HTH

Robert



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to