werner wrote:
> Michael,
>
> Following is just a suggestion.
> ...
>> that sounds very strange.  0.4 and earlier would use TEXT for String
>> with
>> no size.  In 0.5 we did away with that, as its a surprise - we had lot
>> of
>> "string with no length" complaints, but I would prefer people learn
>> about
>> String/String(50) instead of assuming that String always needs a length,
>> since that adds to the "verbose" narrative which really isn't true.
> When I started to use SA I also thought one had to be very verbose until
> you showed me some tricks.
>
> If "verbose" is still something "hanging" on SA I would suggest to
> change the tutorials, e.g. to something like this:
>
> Most tutorial/sample code for declarative show something like this:

OK i see the point about the constructor, though I want to get across that
yes the constructor is optional with declarative, but you can still make
one.   that might be too much to ask.   as far as Sequence and such, I
still would rather leave those out of the examples - since we're on Sphinx
I should learn to put a little "sidebox" type of thing that lays out those
issues straight in the tutorial when the mapping is first introduced, i.e.
with mysql, fb, oracle, etc. you need to consider XYZ.


>
> class User(Base):
>      """"""
>      __tablename__ = "users"
>
>      id = Column(Integer, primary_key=True)
>      name = Column(String)
>      fullname = Column(String)
>      password = Column(String)
>
>      #----------------------------------------------------------------------
>      def __init__(self, name, fullname, password):
>          """Constructor"""
>          self.name = name
>          self.fullname = fullname
>          self.password = password
>
>      def __repr__(self):
>          return "<User('%s','%s', '%s')>" % (self.name, self.fullname,
> self.password)
>
> Much shorter would be the following and I believe it would work with all
> databases.
>
> class User(Base):
>      """"""
>      __tablename__ = "users"
>
>      id = Column(Integer, Sequence('users_id'), primary_key=True)
>      name = Column(String(30))
>      fullname = Column(String(30))
>      password = Column(String(20))
>
> Then in the text explain that "sequence" and (30) is only needed with
> certain db's.
>
> Use the above type of definition with the following:
>
> class BaseExt(object):
>      """Does much nicer repr/print of class instances
>      from sqlalchemy list suggested by Michael Bayer
>      """
>      def __repr__(self):
>          return "%s(%s)" % (
>                   (self.__class__.__name__),
>                   ', '.join(["%s=%r" % (key, getattr(self, key))
>                              for key in sorted(self.__dict__.keys())
>                              if not key.startswith('_')]))
>
> Base = declarative_base(cls=BaseExt)
>
> Werner
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to