You'll want to call request.switch_wiki() like this orig_wiki = request.config.wiki_name request.switch_wiki(config.wiki_name) # global 'base' wiki * do stuff here * request.switch_wiki(orig_wiki)
On Sat, Jul 17, 2010 at 3:39 PM, Sean Robinson <seankrobin...@gmail.com> wrote: > On Thu, Jul 15, 2010 at 5:26 PM, Philip Neustrom <phil...@gmail.com> wrote: >> >> Looks basically good. >> >> One note, though: This is going to grab the blacklist page on a >> per-wiki basis, rather than being global. You'll want to specific a >> wiki id in there to grab from the hub (primary) wiki. >> >> -p >> >> On Thu, Jul 15, 2010 at 5:03 PM, Sean Robinson <seankrobin...@gmail.com> >> wrote: >> > On Sat, Jul 10, 2010 at 4:01 PM, Ryan Tucker <rtuc...@gmail.com> wrote: >> >> >> >> On Sat, Jul 10, 2010 at 5:06 PM, Sean Robinson >> >> <seankrobin...@gmail.com> >> >> wrote: >> >> > After looking at blacklist.py (but not running it), it appears that >> >> > the list of restricted URLs are hard coded into the source file. Is >> >> > anyone >> >> > interested in making this use a wiki page for the list of URLs? >> >> >> >> If someone's looking for inspiration on how to retrieve the list from >> >> a wiki page, the spell-checking code does this. There's probably some >> >> good room for code reuse (or modularization!) there, for sure. -rt >> >> >> > >> > The following is an attempt at a new blacklist.py. I am seeking >> > comments >> > and criticism to see if I understood what I was reading in the spell >> > check >> > code and whether I am using PageEditor correctly, etc. This is an early >> > draft of non-working code, but I would appreciate feedback about my >> > approach. >> > >> > # -*- coding: utf-8 -*- >> > # blacklist against wiki spammers >> > >> > # WikiSpot admins can add a URL to 'Global Blacklist Page' to disallow >> > an >> > # edit which contains that URL. >> > >> > import re, types >> > from Sycamore import config >> > from Sycamore.PageEditor import PageEditor >> > from Sycamore.request import RequestDummy >> > from Sycamore.security import Permissions >> > >> > # get the global blacklist page contents >> > request = RequestDummy() >> > blacklist_page = PageEditor(config.global_blacklist_page, request) >> > if blacklist_page: >> > blacklist = blacklist_page.get_raw_body() >> > self.blacklist_re = "|".join(map(lambda s: "%s" % s.strip(), >> > blacklist.strip().split("\n"))) >> > self.blacklist_re = re.compile(self.blacklist_re) >> > >> > class SecurityPolicy(Permissions): >> > def save(self, editor, newtext, datestamp, **kw): >> > match = blacklist_re.search(newtext) >> > if match: >> > print "blacklist match: %s" % match.group() >> > return match == None >> > >> > > > How do I create multiple wikis in a local Sycamore install? I would like > to test using the hub wiki blacklist page from child wikis. > > Below is a second version that works within limits and has been tested on > a local Sycamore install. I would again appreciate comments. > > # -*- coding: utf-8 -*- > # blacklist against wiki spammers > > # WikiSpot admins can add a URL to 'Global Blacklist' to disallow an > # edit which contains that URL. > > from Sycamore.security import Permissions > > class SecurityPolicy(Permissions): > def save(self, editor, newtext, datestamp, **kw): > # do not enforce URL blacklisting in blacklist page > if editor.request.pagename == > editor.request.config.page_global_blacklist: > return True > > import re, types > from Sycamore.PageEditor import PageEditor > > blacklist_page = > PageEditor(editor.request.config.page_global_blacklist, editor.request) > if blacklist_page: > blacklist = blacklist_page.get_raw_body() > blacklist_re = "|".join(map(lambda s: "%s" % s.strip(), > blacklist.strip().split("\n"))) > blacklist_re = re.compile(blacklist_re) > > match = blacklist_re.search(newtext) > > if match: > print "blacklist match: %s" % match.group() > return match == None > > -- > Sean Robinson > WiFi Radar - http://wifi-radar.berlios.de > Python WiFi - http://pythonwifi.wikispot.org > > > _______________________________________________ > Sycamore-Dev mailing list > sycamore-...@wikispot.org > http://www.projectsycamore.org/ > https://tools.cernio.com/pipermail/sycamore-dev/ > https://tools.cernio.com/mailman/listinfo/sycamore-dev > > _______________________________________________ Sycamore-Dev mailing list sycamore-...@wikispot.org http://www.projectsycamore.org/ https://tools.cernio.com/pipermail/sycamore-dev/ https://tools.cernio.com/mailman/listinfo/sycamore-dev