def delAndPurge(): """ """ parser = argparse.ArgumentParser() parser.add_argument('--conf', help='wsgi conf file') parser.add_argument('--userid', help='user id') args = parser.parse_args() config = ConfigParser.RawConfigParser() config.read(args.conf) server = couchdbkit.Server(config.get('app:main', 'couchdb.url')) db = server.get_or_create_db(config.get('app:main','couchdb.db')) User.set_db(db) Link.set_db(db) push('couchdb/_design/purge', db) try: user = User.get(args.userid) user.delete() print "%s is now deleted" % args.userid except couchdbkit.exceptions.ResourceNotFound: print "%s not found" % args.userid links = Link.view('purge/all', key=args.userid, include_docs=True) print "%d links found" % len(links) for link in links: link.delete() print "job done"
def coherence(): """ """ parser = argparse.ArgumentParser() parser.add_argument('--conf', help='wsgi conf file') parser.add_argument('--userid', help='user id') args = parser.parse_args() config = ConfigParser.RawConfigParser() config.read(args.conf) server = couchdbkit.Server(config.get('app:main', 'couchdb.url')) db = server.get_or_create_db(config.get('app:main','couchdb.db')) User.set_db(db) Link.set_db(db) users = User.view('user/all', descending=True) for user in users: print "user %s" % user._id links = Link.view('purge/all', key=user._id, include_docs=True) for link in links: print "checking %s" % link._id if link._id not in user.links: print "adding %s" % link._id user.links[link._id] = link.created user.save()
import couchdbkit from couchdbkit.designer import push from PIL import Image from wsgiwars.models.user import User from wsgiwars.models.link import Link from wsgiwars.resources import linkAjax settings = get_current_registry().settings server = couchdbkit.Server(settings['couchdb.url']) db = server.get_or_create_db(settings['couchdb.db']) User.set_db(db) Link.set_db(db) for view in ['couchdb/_design/user', 'couchdb/_design/public', 'couchdb/_design/user_link', 'couchdb/_design/my_link', 'couchdb/_design/viewTag', 'couchdb/_design/viewFollowers', 'couchdb/_design/contacts_links', 'couchdb/_design/tags', ]: push(view, db) avatarSize = 128,128 def limitAndPage(request):