I have followed the instructions at
http://docs.turbogears.org/1.0/CreatingBigApplications.
There are a few things to mention.
When splitting the model then in <yourpackage>.egg-inf/sqlobject.txt the
different models should be included.
In the example:
db_module=blog.model
should be changed in:
db_module=blog.model.base, blog.model.public, blog.model.internal.
One strange thing here. Te identity classe where first part of another class
(in my case tblog). I thought it better to put them in a file by themselve
(identity.py). When the classes where in tblog.py they where displayed by
tg-admin sql list, but after putting into there own file, they where not
displayed anymore. What could be the problem?
In sqlobject.txt I have:
db_module=tblog.model.identity, tblog.model.blog,
tblog.model.feedingList
identity.py starts with:
#####
from datetime import datetime
import pkg_resources
pkg_resources.require("SQLObject>=0.8,<=0.10.0")
from turbogears.database import PackageHub
# import some basic SQLObject classes for declaring the data model
# (see http://www.sqlobject.org/SQLObject.html#declaring-the-class)
from sqlobject import SQLObject, SQLObjectNotFound, RelatedJoin
# import some datatypes for table columns from SQLObject
# (see http://www.sqlobject.org/SQLObject.html#column-types for more)
from sqlobject import BoolCol, DateCol, DateTimeCol, EnumCol, ForeignKey,
IntCol, MultipleJoin, StringCol, UnicodeCol
from turbogears import identity
__connection__ = hub = PackageHub('tblog')
# the identity model
class Visit(SQLObject):
"""
A visit to your site
"""
class sqlmeta:
table = 'visit'
visit_key = StringCol(length=40, alternateID=True,
alternateMethodName='by_visit_key')
created = DateTimeCol(default=datetime.now)
expiry = DateTimeCol()
def lookup_visit(cls, visit_key):
try:
return cls.by_visit_key(visit_key)
except SQLObjectNotFound:
return None
lookup_visit = classmethod(lookup_visit)
#####
There is mentioned that when splitting the controller, that all the py-files
should be imported in the __init__.py file. But when I only put the root.py
in, everything seems to work. Is it neccesary to put all the py-files into
__init__.py or not?
Lastly, when I was working with one controller and one model file I imported
my model with
from model import ...
after splitting I need
from tblog.model import ...
Is this correct, or am I doing something wrong?
--
Cecil Westerhof
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---