twisted / twisted

Event-driven networking engine written in Python.
https://www.twisted.org
Other
5.43k stars 1.14k forks source link

getData returning a Deferred doesn't seem to work. #7071

Closed twisted-trac closed 20 years ago

twisted-trac commented 20 years ago
jyknight's avatar @jyknight reported
Trac ID trac#317
Type defect
Created 2003-10-06 22:54:46Z
Searchable metadata ``` trac-id__317 317 type__defect defect reporter__jknight jknight priority__high high milestone__ branch__ branch_author__ status__closed closed resolution__fixed fixed component__ keywords__ time__1065480886000000 1065480886000000 changetime__1076053242000000 1076053242000000 version__ owner__ cc__dp cc__jknight ```
twisted-trac commented 13 years ago
Automation's avatar Automation removed owner
twisted-trac commented 20 years ago
jyknight's avatar @jyknight commented
#!html
<pre>
I have code that looks like follows (request.dbpool does in fact exist in my code):

class DatabaseJunk(model.Model):
    def getData(self, request):
        return request.dbpool.runQuery("""select * from stuff""")

class Page(page.Page):
    wmfactory_db(self, request):
        return DatabaseJunk()

and, when i request in main.html the model be rendered like:
&lt;span view="Text" model="/db" />

woven gets stuck in an infinite loop. This is happening because of the first 3 lines in 
widgets.py setDataCallback. It calls setData and then getData when the deferred from the first call  
to getData returns. However, getData always returns a Deferred and is unaffected by setData. 
Thus, infinite loop.

Now, before you say my getData is buggy, I will refer you to the woven howto, section "7.3.4 
IModel Adapters".

I 'fixed' this by commenting out those 3 lines and replacing them with "data = result".

I'd also like to point out there, that it shows how you can override setData to update the database. 
Clearly this is a bad idea if the woven framework is going to calling setData behind the scenes.
</pre>
twisted-trac commented 20 years ago
jyknight's avatar @jyknight commented
#!html
<pre>
This bug is being resolved, wontfix, as woven is "almost deprecated" and unmaintained. Use nevow 
instead. See &lt;http://divmod.org/users/dp.twistd/wiki/> and the twisted-web mailing list &lt;http://
twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web>.
</pre>