I am reworking my own shareware model (upgrade to SA 0.7 and refactor
some stuff) and as I like to use it at some point in a TG application I
have looked at a quickstarted application model to see how things are
done for TG 2.1.
What are the "#{ Columns" tags and similar used for? Are they for some
documentation tool, if yes is it a Sphinx extension which does something
with them? Looked at the 2.1 doc
(http://www.turbogears.org/2.1/docs/main/explorequickstart.html) but
they are not mentioned there.
In model.auth I see "__all__ = ['User', 'Group', 'Permission']" but in
model.__init__ the import is "from example.model.auth import User,
Group, Permission" would using "from example.model.auth import *" be an
acceptable use here or is this still considered bad?
I find having "def __repr__" in different models very repetitive, maybe
something like this could be used instead.
class BaseExt(object):
"""Provides a nicer representation when a class instance is printed.
Found on the SA wiki or mail list
"""
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('_')]))
DeclarativeBase = sad.declarative_base(cls=BaseExt)
The model.model_template imports are:
from sqlalchemy import *
from sqlalchemy.orm import mapper, relation
from sqlalchemy import Table, ForeignKey, Column
from sqlalchemy.types import Integer, Unicode
from sqlalchemy.orm import relation, backref
Wouldn't something like this be clearer for noobies and help to
immediately see where things come from?
import sqlalchemy as sa
import sqlalchemy.orm as sao
import sqlalchemy.sql as sasql
import sqlalchemy.ext.declarative as sad
Werner
--
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.