Thank you both Marlin and Pavel,

That all makes a lot of sense and wasn't really explained in the
documentation. Appreciate your time and attention.

Kind regards

Hansel

On Jan 14, 1:12 pm, Pavel Strashkin <[email protected]> wrote:
> 1. I'm agree with Marlin. It's better don't use yourself constructor
> in case of SqlObject or SqlAchemy. Use keywords arguments instead.
> 2.http://docs.python.org/library/functions.html#super(there is you
> can read about super and how to use it with a new-style classes)
>
> 2011/1/14 Marlin Forbes <[email protected]>:> On 14/01/2011 14:35, hansel 
> wrote:
>
> > Hi Marlin and Pavel, thanks for the response.
>
> > No, I'm not using super(). I can't find any documentation on this
> > class. Could you point me towards some? An example of what I mean is
> > below. The class below won't be able to create new rows in the admin
> > interface unless I comment out the three lines of the __init__ method.
> > It fails with an error like "class 'Company' requires three
> > arguements, only one given."
>
> > You want to do something like this:
>
> > class Company(DeclarativeBase):
> >     __tablename__ = 'companies'
>
> >     def __init__(self, name, company_symbol, **kwargs):
> >         super(Company, self).__init__(**kwargs)
> >         self.name = name
> >         self.company_symbol = company_symbol
>
> > AFAIK, the DeclarativeBase constructor fills in attributes from kwargs
> > anyway, so you could get away with not using the constructor at all, and
> > simply creating new Companies like this:
>
> >     company1 = Company(name='company', company_symbol='somesymbol')
>
> > class Company(DeclarativeBase):
> >     __tablename__ = 'companies'
>
> >     id = Column(Integer, primary_key = True)
> >     name = Column(String, nullable = False)
> >     company_symbol = Column(String)
>
> >     def __init__(self, name, company_symbol):
> >         self.name = name
> >         self.company_symbol = company_symbol
>
> >     def __repr__(self):
> >         return "<Company('%s', '%s')>" % self.name,
> > self.company_symbol
>
> > Kind regards
>
> > Hansel
>
> > On Jan 13, 2:24 pm, Pavel Strashkin <[email protected]> wrote:
>
> > Hi,
>
> > Could you please provide an example? Do you call superclass __init__
> > method in your class?
>
> > 2011/1/13 Hansel Dunlop <[email protected]>:
>
> > Hi there,
>
> > First off I want to say thank you to everyone that has spent their time
> > developing the TurboGears stack. It's great!
>
> > I have one question, or maybe it's a comment.
>
> > If you create your data models with '__init__' methods then the admin
> > interface is no longer able to add rows into the database. Is this by
> > design? I am just curious about the rationale and how it can be easily
> > changed.
>
> > Kind regards
>
> > Hansel
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "TurboGears" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/turbogears?hl=en.-Hide quoted text -
>
> > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "TurboGears" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/turbogears?hl=en.

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

Reply via email to