Alright, I know this is probably a newbie question and there's something
obvious I'm missing.  I'm not new to python but this is my first forray into
TurboGears (I've done a handful of follow-along tutorials along with my own
CherryPy stuff in the past).

So basically, I'm getting the following error in one of my pages:

----
File "model.py", line 126, in score
    return sum( [v.score for v in Vote.select( Vote.q.site == self.id)] )
  File
"/usr/lib/python2.5/site-packages/SQLObject-0.9.1-py2.5.egg/sqlobject/sqlbuilder.py",
line 381, in __getattr__
    raise AttributeError("%s instance has no attribute '%s'" %
(self.soClass.__name__, attr))
AttributeError: Vote instance has no attribute 'site'
Error location in template file 'templates/site.kid'
between line 8 and line 9:
<body>
  Site: ${site.url} with score: [b]${site.score()}[/b][/quote]
----

model.py:
----
# tg-admin generated objects are here

#my code:
class Site(SQLObject):
    url = UnicodeCol(length=512)     
    url_text = UnicodeCol(length=255)
    submitter = ForeignKey('User')
    timestamp = DateTimeCol(default=datetime.now)
    approved = IntCol()
    blurb = StringCol(length=4096)
    
    def score(self):
        return sum( [v.score for v in Vote.select( Vote.q.site == self.id)]
)
     
class Vote(SQLObject):
    site = ForeignKey('Site')
    user = ForeignKey('User')
    score = IntCol()    # {-1,1}
    timestamp = DateTimeCol(default=datetime.now)
----

controller.py:
----
# tg-admin created code here

#my addition to the root class:
    @expose(template="projectname.templates.site")
    def site(self, sid):
        site = Site.selectBy(id==sid)[0]
        return dict(site=site)
----


Any ideas?  I had almost identical (I think it was identical, but I've
tweaked it a number of times so I can't remember) code running on an older
version of Turbogears that I have on my laptop, but not under the latest
turbogears.

Here's my system info:
----
    *   TurboGears 1.0.4b1
    * SQLAlchemy 0.3.10
    * TurboKid 1.0.3
    * TurboJson 1.1
    * TurboCheetah 0.9.5
    * simplejson 1.7.3
    * setuptools 0.6c6
    * RuleDispatch 0.5a0.dev-r2306
    * PasteScript 1.3.6
    * FormEncode 0.7.1
    * DecoratorTools 1.5
    * configobj 4.4.0
    * CherryPy 2.2.1
    * Cheetah 2.0rc8
    * kid 0.9.6
    * RuleDispatch 0.5a0.dev-r2306
    * Cheetah 2.0rc8
    * PyProtocols 1.0a0dev-r2302
    * PasteDeploy 1.3.1
    * Paste 1.4.2
    * DecoratorTools 1.5
---
-- 
View this message in context: 
http://www.nabble.com/SQLObject-Issue-tf4744280.html#a13566515
Sent from the Turbogears General mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
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