Closed twisted-trac closed 20 years ago
dp commented |
---|
#!html
<pre>
As I said in that irc conversation, I believe the correct way to solve this problem is to make
getSubmodel work like submodelFactory does right now and deprecate the use of
submodelFactory.
</pre>
@moshez commented |
---|
#!html
<pre>
they are different.
getSubmodel returns a model, submodelFactory returns something
which gets turned into a model. They are different.
You usually want to override neither, you want to use MethodModel
or AttributeModel. If you don't, then you probably should override
from getSubmodel and just use adaptToIModel if necessary.
I don't think this is a bug. "getSubmodel", by its very name,
should return a model.
</pre>
@jyknight commented |
---|
#!html
<pre>
Doc bugs are still bugs. I realize the methods are different (now) -- my issue is that the
documentation did not tell me that, or even tell me that submodelFactory existed.
Also:
[11:18] <foom> is there any reason to ever override getSubmodel instead of submodelFactory?
[11:19] <glyph> foom: nope
[11:19] <foom> okay, then there's a doc bug
[11:20] <fzZzy> foom: basically submodelFactory should be renamed getSubmodel and the code
in getSubmodel should be moved higher up into the framework
[11:20] <glyph> foom: one among many :-\. fzZzy and I have been discussing this rather
systematic problem of woevn for the last day or two
</pre>
dp commented |
---|
#!html
<pre>
It should be pretty easy to do without a total rewrite. Also, woven2 will probably not be as much of
a total rewrite as a refactoring with a chainsaw on fire.
Anyway, thanks for raising it, I'll try to find time to get this in as soon as possible.
</pre>
@moshez commented |
---|
#!html
<pre>
The following patch looks like it does the right thing:
Index: twisted/web/woven/model.py
===================================================================
RCS file: /cvs/Twisted/twisted/web/woven/model.py,v
retrieving revision 1.51
diff -u -r1.51 model.py
--- twisted/web/woven/model.py 6 Oct 2003 15:10:17 -0000 1.51
+++ twisted/web/woven/model.py 24 Oct 2003 17:30:49 -0000
@@ -170,7 +170,7 @@
elif element == '..':
currentModel = currentModel.parent
else:
- currentModel = currentModel.getSubmodel(request, element)
+ currentModel = currentModel._getSubmodel(request, element)
if currentModel is None:
return None
return currentModel
@@ -200,11 +200,15 @@
Deferred, then I ought to check for cached values (created by
L{setSubmodel}) before doing a regular Deferred lookup.
"""
+ return self.submodelFactory(request, name)
+
+
+ def _getSubmodel(self, request, name):
if self.submodels.has_key(name):
return self.submodels[name]
if not self.submodelCheck(request, name):
return None
- m = self.submodelFactory(request, name)
+ m = self.getSubmodel(request, name)
if m is None:
return None
sm = adaptToIModel(m, self, name)
</pre>
Searchable metadata
``` trac-id__316 316 type__defect defect reporter__jknight jknight priority__high high milestone__ branch__ branch_author__ status__closed closed resolution__fixed fixed component__ keywords__ time__1065480378000000 1065480378000000 changetime__1076053203000000 1076053203000000 version__ owner__dp dp cc__dp cc__jknight ```