On Feb 11, 6:04 am, Oveek <[email protected]> wrote:
> I think I'm right in saying that it's currently not possible to use
> TiddlyWiki's import function (the one accessed through the backstage)
> under TiddlyWeb.
Pretty much yeah, this came up yesterday for someone else as well. You
can do some hackery if you take the wiki that TiddlyWeb produces
offline (using wget, curl or adding download=<filename> to the
parameter string of the URL), but you then run into issues with some
of the server.* fields. FND and JonL got something working yesterday
so it would be cool if they posted something, somewhere, about what
they did.
> Unless I'm very much mistaken a php proxy script is not an option when
> TiddlyWeb is used standalone. I do recall reading that it's possible
> to run TiddlyWeb under another web server, like Apache, in which case
> BidiX's proxy service should work.
That's all correct. There are some rough instructions on how to mount
TiddlyWeb under apache at:
http://peermore.com:8080/recipes/AutoTiddlyWeb/tiddlers/HowToModWSGI
http://peermore.com:8080/recipes/AutoTiddlyWeb/tiddlers/HowToModPython
> Still it would be nice to have this feature natively, without needing
> a php enabled server, and I don't think it would be very difficult to
> do. Essentially TiddlyWeb needs a python proxy, a python counterpart
> to the php proxy script.
Agreed, and a very good idea.
> I'd like to know the proper way to implement this in TiddlyWeb. My
> guess from looking at the code is something like this:
>
> *Add a new URL map to urls.map, like: /proxy[.{url}].
> *Write a corresponding handler, tiddlyweb.web.handler.proxy, that
> mimics proxy.php.
This is essentially correct, but you can do it in a plugin, and thus
not need to get into the core codebase at all, if you want.
You may have seen me post about the plugin tutorial that I've started
on my blog:
http://cdent.tumblr.com/post/76922695/1-tiddlyweb-tutorial
> ...that was almost too short for a bullet list, maybe I'm missing some
> steps.
Not really, it really is that short. You need to add a route to the
Selector map, and add a handler to support that route. Let's do it
right here. First you need to create the initial plugin file in your
instance and let TiddlyWeb know it exists by adding a reference to it
in tiddlywebconfig.py:
-=-=-
config = {
'secret': '8cb5aadff2f62bXXXXX0bba2f29e96b2c50e4d22',
'system_plugins': ['proxy'],
}
-=-=-
and then creating proxy.py:
-=-=-
import urllib2
def proxy(environ, start_response):
url = environ['tiddlyweb.query']['url'][0]
getter = urllib2.urlopen(url)
start_response('200', [])
return getter.read()
def init(config):
config['selector'].add('/proxy', GET=proxy)
-=-=-
If you start up your server and go to http://0.0.0.0:8080/proxy?url=<some
url> the output of some_url will show up, at least for basic cases.
Mind you this has large problems:
* It's an open proxy, anybody can use it to get whatever they want.
* It completely disregards request and response headers, and really
shouldn't do that.
The first problem can be addressed by requiring some authentication of
some kind for the proxy method. The tiddlyweb-plugins package comes
with require_any_user and require_role decorators that might be
useful.
The second problem can be addressed by paying more attention to the
incoming request, constructing a proper request to the target server
and attending to its response. Rather than writing all that code it is
probably possible to just use a WSGI proxy that somebody else has
written. The Paste project is probably a good place to start:
http://pythonpaste.org/
> That would be the server proxy part.
Yup.
> When the url to the target wiki (the wiki to import tiddlers from) is
> entered into the backstage import wizard, the proxy address is
> automatically prepended to the url. This should trigger the /proxy URL
> map, and invoke the handler, which should download the intended
> TiddlyWiki and make it possible to import tiddlers.
That's cool.
> Seems pretty easy, the main thing is to write a proxy in python and
> use it as a handler. Please fill in any gaps and tell me if this is
> indeed possible. I'll be really embarassed if there's already a way to
> do this. I'm aware of twanager's importing capability, which is great
> for whole wikis, but the TiddlyWiki import wizard makes it easy to
> import individual tiddlers.
I think you've nailed it. If you cook up a more reasonable proxy
plugin, please publish it somewhere, it will be very useful, or send
me some patches to what I've started above and I'll stick it in the
tiddlywiki code repo.
The proxy settings that Reenen describes in another message are for
making things like "twanager from_svn" work when behind an
authenticating proxy firewall.
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" 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/TiddlyWikiDev?hl=en
-~----------~----~----~----~------~----~------~--~---