> Hey guys, I've started a very limited tiddlywebwiki deployment on our
> intranet with one or two users to help me test.
\o/
> There are various areas I hope to smooth out before a major deployment
> though and I'll bring them up in separate posts. I've got a list :)
*hides*
> 1) txtUserName is not being set properly under IE after switching
> between users. I think this is related to IE's cookie handling. Here
> are the steps to reproduce:
This may be related to how IE is doing caching of requests back to /
status from the TiddlyWebConfig plugin (assuming you are using the
status plugin).
Below is a diff for status.py. If you could give that a poke, that
would be useful. What that ought to do is tell the browser to go back
to the server to ask for /status again, each time. It may not though,
as caching never seems to work like one expects.
> context.serverStatus.username gets set. I started tracing it back, but
> I became cross eyed and fell out of my chair. I think it comes from
> userParams but I'm not too sure.
Javascript makes me fall out of my chair too.
> * Reopen the wiki from the same recipe and look at the same tiddler as
> before. The tiddler still shows only a view link even though you're
> now logged in as User2 with write access on the bag.
> * Clear the cache, reload the page, and view the same tiddler. Now the
> tiddler will show the edit link as it should.
You seem to have correctly interpreted what's going on here. The
browser is caching the wiki with an ETag. When the second user loads
the wiki the browser validates the ETag against the server and the
server says, "yah, we still got the same ETag, you go ahead and use
what you've got cached".
However the content shouldn't be considered the same because of the
change in the server.perms attribute on the tiddlers that ought to be
there.
I can think of a few ways around this in various combinations:
* Include the current user in the ETag generation routines.
* Always use lazy loading when retrieving tiddlers (so we cache the
wiki framework but not the tiddlers themselves)
* Turn off caching when tiddlyweb.user is not GUEST.
There's a sense to which the first one is probably a correct thing to
do, around line 60 in tiddlyweb/web/sendtiddlers.py
Thoughts?
> ...More stuff to come in due course.
I'm trembling.
diff --git a/status/status.py b/status/status.py
index 1248c54..f113571 100644
--- a/status/status.py
+++ b/status/status.py
@@ -6,6 +6,7 @@ def status(environ, start_response):
data = _gather_data(environ)
output = simplejson.dumps(data)
start_response('200 OK', [
+ ('Cache-Control', 'no-cache'),
('Content-Type', 'application/json')
])
return [output]
>> I can think of a few ways around this in various combinations:
>>
>> * Include the current user in the ETag generation routines.
>> * Always use lazy loading when retrieving tiddlers (so we cache the
>> wiki framework but not the tiddlers themselves)
>> * Turn off caching when tiddlyweb.user is not GUEST.
>>
>> There's a sense to which the first one is probably a correct thing to
>> do, around line 60 in tiddlyweb/web/sendtiddlers.py
>>
>> Thoughts?
>
> I agree, I think the first option is the correct thing to do.
As I was coding this up, I realized it was going to break some of the
caching optimizations that I've been experimenting with, such as the
cachinghoster plugin[1]. I think this indicates a problem in the
cachinghoster, not in this solution, but it does mean I'm going to
think about it for a while before committing.
I've checked the change in on a branch:
http://github.com/tiddlyweb/tiddlyweb/commit/1aebf5de49bf1314564adcdf6d48722844f8664d
[1] http://github.com/tiddlyweb/tiddlyweb-plugins/tree/master/cachinghoster
I agree that this seems like the appropriate solution. (Even though it
seems a little hacky, as the same URI represents different views for
different users... )
> I've checked the change in on a branch
Am I right in assuming that only only tiddler collections' ETags are
affected by this change - i.e. individual tiddlers continue to use
"bag/title"?
If that's correct, no change should be required in the TiddlyWebAdaptor.
-- F.
The only way I can think of right now is on-demand loading - but that
would mean we'd have to write custom handlers for the relevant bits
(currently only toolbar commands) to accommodate the asynchronous nature
of such operations.
> Which feature is more important large-area web caching or simple way
> to get at tiddler permissions?
Well, if it really comes down to it, caching seems more important - if
only because the client-side could adapt.
However, the issue might be more complicated:
> the server.perms attribute [...] is the thing which makes tiddlywikis
> different from user to user
I don't think permissions are the only variable here; user bags (i.e.
"{{ user }}" in recipes) have the same effect.
Both of these factors undermine the notion of "the same URI will always
return the same content", which might be an issue that transcends the
TiddlyWebWiki vertical.
-- F.
>> the server.perms attribute [...] is the thing which makes tiddlywikis
>> different from user to user
>
> I don't think permissions are the only variable here; user bags (i.e.
> "{{ user }}" in recipes) have the same effect.
> Both of these factors undermine the notion of "the same URI will
> always
> return the same content", which might be an issue that transcends the
> TiddlyWebWiki vertical.
I should have been more explicit: "different from user to user when
the tiddlers involved are the same".
The context for this discussions is the situation where the ETag for a
list of tiddlers is the same between two documents, but the content of
the documents is different. That's bad because it causes the problem
Oveek saw when switching between users in the same browser.
When using user bags, the ETag will be different, even though the URI
is the same, because the ETag is generated from a hash of
bag_name:tiddler_title of all tiddlers in the collection of tiddlers.
"same URI will always return the same content" is a bit strict. The
idea is that the same URI will consistently return the same
representation, modulo various headers. So as '/' at twitter.com is
the current users home page, so too can /recipes/dyanuser/tiddlers be
a known thing that might have different content depending on the user.
You're right, I hadn't taken that into account.
So I guess the conclusion is that the server.permissions field will be
removed from the wiki serialization?
I'm okay with that, but would prefer for this to be checked in on a
branch so I have time to adjust the client-side accordingly.
I don't think anybody else is making use of that field so far.
> "same URI will always return the same content" is a bit strict
Yes, I guess you're right - not sure what Roy would say though... (Not
that we had to be REST purists, of course.)
-- F.
We've agreed that's not required, for now.
It suffices to re-request the permissions on demand.
I've checked in an experimental plugin for this purpose:
http://trac.tiddlywiki.org/browser/Trunk/association/plugins/ServerSideToolbarCommands.js
Since this is largely untested and still has some rough edges, I have
not yet removed the permissions handling from TiddlyWebConfig.
A review of this approach would be most welcome.
Also, I don't like the name "ServerSideToolbarCommands", so alternative
suggestions would be great.
-- F.