allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/4] git commit: Exploratory work debugging strange controller/import issues with TG 2.2
Date Mon, 10 Dec 2012 16:36:55 GMT
Updated Branches:
  refs/heads/db/tg2.2 [created] c58db09eb


Exploratory work debugging strange controller/import issues with TG 2.2

Running `nosetests -v forgeblog/tests/test_commands.py forgeblog.tests.functional.test_root:TestRootController.test_simple`
fails, but omitting test_commands.py works.  Seems to be something about
importing the app & controller that is under test causes problems.


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c58db09e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c58db09e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c58db09e

Branch: refs/heads/db/tg2.2
Commit: c58db09eb34c50aee80b80601a5d0a52435511bd
Parents: 8abda8b
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Mon Dec 10 16:34:53 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Mon Dec 10 16:36:17 2012 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/base.py                  |   12 +-
 Allura/allura/controllers/basetest_project_root.py |    9 +-
 ForgeBlog/forgeblog/command/rssfeeds.py            |  124 +-----
 ForgeBlog/forgeblog/main.py                        |  420 +--------------
 ForgeBlog/forgeblog/tests/functional/test_root.py  |    7 +-
 ForgeBlog/forgeblog/tests/test_commands.py         |  177 ------
 run_tests                                          |    1 -
 7 files changed, 25 insertions(+), 725 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c58db09e/Allura/allura/controllers/base.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/base.py b/Allura/allura/controllers/base.py
index b7f540b..4ba9566 100644
--- a/Allura/allura/controllers/base.py
+++ b/Allura/allura/controllers/base.py
@@ -1,15 +1,9 @@
-from tg import expose
-from webob import exc
-from tg.controllers.dispatcher import ObjectDispatcher
+from crank.objectdispatcher import ObjectDispatcher
 
 
 class BaseController(object):
-    @expose()
-    def _lookup(self, name, *remainder):
-        """Provide explicit default lookup to avoid dispatching backtracking
-        and possible loops."""
-        raise exc.HTTPNotFound, name
-
+    # in previous versions of TG, we needed to override _lookup for special workaround handling
+    pass
 
 class DispatchIndex(object):
     """Rewrite default url dispatching for controller.

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c58db09e/Allura/allura/controllers/basetest_project_root.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/basetest_project_root.py b/Allura/allura/controllers/basetest_project_root.py
index 2c25f5f..bd059c9 100644
--- a/Allura/allura/controllers/basetest_project_root.py
+++ b/Allura/allura/controllers/basetest_project_root.py
@@ -10,7 +10,7 @@ from webob import exc
 from tg import expose
 from tg.decorators import without_trailing_slash
 
-import  ming.orm.ormsession
+import ming.orm.ormsession
 
 import allura
 from allura.lib.base import WsgiDispatchController
@@ -30,7 +30,7 @@ __all__ = ['RootController']
 
 log = logging.getLogger(__name__)
 
-class BasetestProjectRootController(WsgiDispatchController, ProjectController):
+class BasetestProjectRootController(WsgiDispatchController):
     '''Root controller for testing -- it behaves just like a
     ProjectController for test/ except that all tools are mounted,
     on-demand, at the mount point that is the same as their entry point
@@ -47,8 +47,8 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
     '''
 
     def __init__(self):
-        setattr(self, 'feed.rss', self.feed)
-        setattr(self, 'feed.atom', self.feed)
+        #setattr(self, 'feed.rss', ProjectController.feed)
+        #setattr(self, 'feed.atom', ProjectController.feed)
         for n in M.Neighborhood.query.find():
             if n.url_prefix.startswith('//'): continue
             n.bind_controller(self)
@@ -63,6 +63,7 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
         super(BasetestProjectRootController, self).__init__()
 
     def _setup_request(self):
+        pass
         # This code fixes a race condition in our tests
         c.project = M.Project.query.get(shortname='test', neighborhood_id=self.p_nbhd._id)
         c.memoize_cache = {}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c58db09e/ForgeBlog/forgeblog/command/rssfeeds.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/command/rssfeeds.py b/ForgeBlog/forgeblog/command/rssfeeds.py
index abbc346..7bb0b39 100644
--- a/ForgeBlog/forgeblog/command/rssfeeds.py
+++ b/ForgeBlog/forgeblog/command/rssfeeds.py
@@ -1,25 +1,12 @@
-from time import mktime
-from datetime import datetime
 import re
-
-import feedparser
-import html2text
-from bson import ObjectId
-
 import base
-from allura.command import base as allura_base
 
-from ming.orm import session
-from pylons import c
 
-from allura import model as M
-from forgeblog import model as BM
-from forgeblog import version
 from forgeblog.main import ForgeBlogApp
-from allura.lib import exceptions
-from allura.lib.decorators import exceptionless
 
-html2text.BODY_WIDTH = 0
+
+
+
 
 re_amp = re.compile(r'''
     [&]          # amp
@@ -39,113 +26,8 @@ re_preserve_spaces = re.compile(r'''
 re_angle_bracket_open = re.compile('<')
 re_angle_bracket_close = re.compile('>')
 def plain2markdown(text, preserve_multiple_spaces=False, has_html_entities=False):
-    if not has_html_entities:
-        # prevent &foo; and &#123; from becoming HTML entities
-        text = re_amp.sub('&amp;', text)
-    # avoid accidental 4-space indentations creating code blocks
-    if preserve_multiple_spaces:
-        text = text.replace('\t', ' ' * 4)
-        text = re_preserve_spaces.sub('&nbsp;', text)
-    else:
-        text = re_leading_spaces.sub('', text)
-    # use html2text for most of the escaping
-    text = html2text.escape_md_section(text, snob=True)
-    # prevent < and > from becoming tags
-    text = re_angle_bracket_open.sub('&lt;', text)
-    text = re_angle_bracket_close.sub('&gt;', text)
     return text
 
 
 class RssFeedsCommand(base.BlogCommand):
     summary = 'Rss feed client'
-    parser = base.BlogCommand.standard_parser(verbose=True)
-    parser.add_option('-a', '--appid', dest='appid', default='',
-                      help='application id')
-    parser.add_option('-u', '--username', dest='username', default='root',
-                      help='poster username')
-
-    def command(self):
-        # If this script creates a new BlogPost, it will create an
-        # activitystream activity for that post. During the saving of the
-        # activity, User.url() will be called. This method defers to an
-        # AuthenticationProvider, which depends on a request being setup in
-        # the current thread. So, we set one up here.
-        import pylons, webob
-        pylons.request._push_object(webob.Request.blank('/'))
-
-        self.basic_setup()
-        self.process_feed = exceptionless(None, log=allura_base.log)(self.process_feed)
-        self.process_entry = exceptionless(None, log=allura_base.log)(self.process_entry)
-
-        user = M.User.query.get(username=self.options.username)
-        c.user = user
-
-        self.prepare_feeds()
-        for appid in self.feed_dict:
-            for feed_url in self.feed_dict[appid]:
-                self.process_feed(appid, feed_url)
-
-    def prepare_feeds(self):
-        feed_dict = {}
-        if self.options.appid != '':
-            gl_app = BM.Globals.query.get(app_config_id=ObjectId(self.options.appid))
-            if not gl_app:
-                raise exceptions.NoSuchGlobalsError("The globals %s " \
-                     "could not be found in the database" % self.options.appid)
-            if len(gl_app.external_feeds) > 0:
-                feed_dict[gl_app.app_config_id] = gl_app.external_feeds
-        else:
-            for gl_app in BM.Globals.query.find().all():
-                if len(gl_app.external_feeds) > 0:
-                    feed_dict[gl_app.app_config_id] = gl_app.external_feeds
-        self.feed_dict = feed_dict
-
-    def process_feed(self, appid, feed_url):
-        appconf = M.AppConfig.query.get(_id=appid)
-        if not appconf:
-            return
-
-        c.project = appconf.project
-        app = ForgeBlogApp(c.project, appconf)
-        c.app = app
-
-        allura_base.log.info("Get feed: %s" % feed_url)
-        f = feedparser.parse(feed_url)
-        if f.bozo:
-            allura_base.log.exception("%s: %s" % (feed_url, f.bozo_exception))
-            return
-        for e in f.entries:
-            self.process_entry(e, appid)
-        session(BM.BlogPost).flush()
-
-    def process_entry(self, e, appid):
-        title = e.title
-        allura_base.log.info(" ...entry '%s'", title)
-        if 'content' in e:
-            content = u''
-            for ct in e.content:
-                if ct.type != 'text/html':
-                    content += plain2markdown(ct.value)
-                else:
-                    html2md = html2text.HTML2Text(baseurl=e.link)
-                    html2md.escape_snob = True
-                    markdown_content = html2md.handle(ct.value)
-                    content += markdown_content
-        else:
-            content = plain2markdown(getattr(e, 'summary',
-                                        getattr(e, 'subtitle',
-                                            getattr(e, 'title'))))
-
-        content += u' [link](%s)' % e.link
-        updated = datetime.utcfromtimestamp(mktime(e.updated_parsed))
-
-        base_slug = BM.BlogPost.make_base_slug(title, updated)
-        b_count = BM.BlogPost.query.find(dict(slug=base_slug, app_config_id=appid)).count()
-        if b_count == 0:
-            post = BM.BlogPost(title=title, text=content, timestamp=updated,
-                            app_config_id=appid,
-                            tool_version={'blog': version.__version__},
-                            state='published')
-            post.neighborhood_id=c.project.neighborhood_id
-            post.make_slug()
-            post.commit()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c58db09e/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 3b46f42..e72e3a5 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -1,56 +1,13 @@
-#-*- python -*-
-import logging
-from datetime import datetime
-import urllib2
 
-# Non-stdlib imports
-import pkg_resources
-import pymongo
-from tg import expose, validate, redirect, flash
-from tg.decorators import with_trailing_slash, without_trailing_slash
-from pylons import g, c, request, response
-import formencode
-from formencode import validators
-from webob import exc
+from tg.decorators import expose
 
-from ming.orm import session
+from allura.app import Application
+from allura.controllers import BaseController
 
-# Pyforge-specific imports
-from allura.app import Application, ConfigOption, SitemapEntry
-from allura.app import DefaultAdminController
-from allura.lib import helpers as h
-from allura.lib.search import search
-from allura.lib.decorators import require_post, Property
-from allura.lib.security import has_access, require_access
-from allura.lib import widgets as w
-from allura.lib.widgets.subscriptions import SubscribeForm
-from allura.lib.widgets import form_fields as ffw
-from allura import model as M
-from allura.controllers import BaseController, AppDiscussionController
-
-# Local imports
-from forgeblog import model as BM
-from forgeblog import version
-from forgeblog import widgets
-
-log = logging.getLogger(__name__)
-
-class W:
-    thread=w.Thread(
-        page=None, limit=None, page_size=None, count=None,
-        style='linear')
-    pager = widgets.BlogPager()
-    new_post_form = widgets.NewPostForm()
-    edit_post_form = widgets.EditPostForm()
-    view_post_form = widgets.ViewPostForm()
-    label_edit = ffw.LabelEdit()
-    attachment_add = ffw.AttachmentAdd()
-    attachment_list = ffw.AttachmentList()
-    preview_post_form = widgets.PreviewPostForm()
-    subscribe_form = SubscribeForm()
+#raise Exception(1)
 
 class ForgeBlogApp(Application):
-    __version__ = version.__version__
+    __version__ = "1.2"
     tool_label='Blog'
     tool_description="""
         Share exciting news and progress updates with your
@@ -73,374 +30,13 @@ class ForgeBlogApp(Application):
     def __init__(self, project, config):
         Application.__init__(self, project, config)
         self.root = RootController()
-        self.admin = BlogAdminController(self)
-
-    @Property
-    def external_feeds_list():
-        def fget(self):
-            globals = BM.Globals.query.get(app_config_id=self.config._id)
-            if globals is not None:
-                external_feeds = globals.external_feeds
-            else:
-                external_feeds = self.default_external_feeds
-            return external_feeds
-        def fset(self, new_external_feeds):
-            globals = BM.Globals.query.get(app_config_id=self.config._id)
-            if globals is not None:
-                globals.external_feeds = new_external_feeds
-            elif len(new_external_feeds) > 0:
-                globals = BM.Globals(app_config_id=self.config._id, external_feeds=new_external_feeds)
-            if globals is not None:
-                session(globals).flush()
-
-    def main_menu(self):
-        return [SitemapEntry(self.config.options.mount_label.title(), '.')]
-
-    @property
-    @h.exceptionless([], log)
-    def sitemap(self):
-        menu_id = self.config.options.mount_label.title()
-        with h.push_config(c, app=self):
-            return [
-                SitemapEntry(menu_id, '.')[self.sidebar_menu()] ]
-
-    @property
-    def show_discussion(self):
-        if 'show_discussion' in self.config.options:
-            return self.config.options['show_discussion']
-        else:
-            return True
-
-    @h.exceptionless([], log)
-    def sidebar_menu(self):
-        base = c.app.url
-        links = [
-            SitemapEntry('Home', base),
-            SitemapEntry('Search', base + 'search'),
-            ]
-        if has_access(self, 'write')():
-            links += [ SitemapEntry('New Post', base + 'new') ]
-        return links
-
-    def admin_menu(self):
-        admin_url = c.project.url() + 'admin/' + self.config.options.mount_point + '/'
-        # temporarily disabled until some bugs are fixed
-        links = [SitemapEntry('External feeds', admin_url + 'exfeed', className='admin_modal')]
-        links += super(ForgeBlogApp, self).admin_menu(force_options=True)
-        return links
-        #return super(ForgeBlogApp, self).admin_menu(force_options=True)
-
-    def install(self, project):
-        'Set up any default permissions and roles here'
-        super(ForgeBlogApp, self).install(project)
+        #self.admin = BlogAdminController(self)
 
-        # Setup permissions
-        role_admin = M.ProjectRole.by_name('Admin')._id
-        role_developer = M.ProjectRole.by_name('Developer')._id
-        role_auth = M.ProjectRole.by_name('*authenticated')._id
-        role_anon = M.ProjectRole.by_name('*anonymous')._id
-        self.config.acl = [
-            M.ACE.allow(role_anon, 'read'),
-            M.ACE.allow(role_auth, 'post'),
-            M.ACE.allow(role_auth, 'unmoderated_post'),
-            M.ACE.allow(role_developer, 'write'),
-            M.ACE.allow(role_developer, 'moderate'),
-            M.ACE.allow(role_admin, 'configure'),
-            M.ACE.allow(role_admin, 'admin'),
-            ]
-
-    def uninstall(self, project):
-        "Remove all the tool's artifacts from the database"
-        BM.Attachment.query.remove(dict(app_config_id=c.app.config._id))
-        BM.BlogPost.query.remove(dict(app_config_id=c.app.config._id))
-        BM.BlogPostSnapshot.query.remove(dict(app_config_id=c.app.config._id))
-        super(ForgeBlogApp, self).uninstall(project)
 
 class RootController(BaseController):
 
-    def __init__(self):
-        setattr(self, 'feed.atom', self.feed)
-        setattr(self, 'feed.rss', self.feed)
-        self._discuss = AppDiscussionController()
-
-    def _check_security(self):
-        require_access(c.app, 'read')
 
     @expose('jinja:forgeblog:templates/blog/index.html')
-    @with_trailing_slash
+    #@with_trailing_slash
     def index(self, page=0, limit=10, **kw):
-        query_filter = dict(app_config_id=c.app.config._id)
-        if not has_access(c.app, 'write')():
-            query_filter['state'] = 'published'
-        q = BM.BlogPost.query.find(query_filter)
-        post_count = q.count()
-        limit, page = h.paging_sanitizer(limit, page, post_count)
-        posts = q.sort('timestamp', pymongo.DESCENDING) \
-                 .skip(page * limit).limit(limit)
-        c.form = W.preview_post_form
-        c.pager = W.pager
-        return dict(posts=posts, page=page, limit=limit, count=post_count)
-
-    @expose('jinja:forgeblog:templates/blog/search.html')
-    @validate(dict(q=validators.UnicodeString(if_empty=None),
-                   history=validators.StringBool(if_empty=False)))
-    def search(self, q=None, history=None, **kw):
-        'local tool search'
-        results = []
-        count=0
-        if not q:
-            q = ''
-        else:
-            results = search(
-                q,
-                fq=[
-                    'state_s:published',
-                    'is_history_b:%s' % history,
-                    'project_id_s:%s' % c.project._id,
-                    'mount_point_s:%s'% c.app.config.options.mount_point ])
-            if results: count=results.hits
-        return dict(q=q, history=history, results=results or [], count=count)
-
-    @expose('jinja:forgeblog:templates/blog/edit_post.html')
-    @without_trailing_slash
-    def new(self, **kw):
-        require_access(c.app, 'write')
-        now = datetime.utcnow()
-        post = dict(
-            state='published')
-        c.form = W.new_post_form
-        return dict(post=post)
-
-    @expose()
-    @require_post()
-    @validate(form=W.edit_post_form, error_handler=new)
-    @without_trailing_slash
-    def save(self, **kw):
-        require_access(c.app, 'write')
-        post = BM.BlogPost()
-        for k,v in kw.iteritems():
-            setattr(post, k, v)
-        post.neighborhood_id=c.project.neighborhood_id
-        post.make_slug()
-        post.commit()
-        M.Thread.new(discussion_id=post.app_config.discussion_id,
-               ref_id=post.index_id(),
-               subject='%s discussion' % post.title)
-        redirect(h.really_unicode(post.url()).encode('utf-8'))
-
-
-    @without_trailing_slash
-    @expose()
-    @validate(dict(
-            since=h.DateTimeConverter(if_empty=None, if_invalid=None),
-            until=h.DateTimeConverter(if_empty=None, if_invalid=None),
-            offset=validators.Int(if_empty=None),
-            limit=validators.Int(if_empty=None)))
-    def feed(self, since=None, until=None, offset=None, limit=None, **kw):
-        if request.environ['PATH_INFO'].endswith('.atom'):
-            feed_type = 'atom'
-        else:
-            feed_type = 'rss'
-        title = '%s - %s' % (c.project.name, c.app.config.options.mount_label)
-        feed = M.Feed.feed(
-            dict(project_id=c.project._id, app_config_id=c.app.config._id),
-            feed_type,
-            title,
-            c.app.url,
-            title,
-            since, until, offset, limit)
-        response.headers['Content-Type'] = ''
-        response.content_type = 'application/xml'
-        return feed.writeString('utf-8')
-
-    @with_trailing_slash
-    @expose('jinja:allura:templates/markdown_syntax_dialog.html')
-    def markdown_syntax_dialog(self, **kw):
-        'Static dialog page about how to use markdown.'
-        return dict()
-
-    @expose()
-    def _lookup(self, year, month, name, *rest):
-        slug = '/'.join((year, month, urllib2.unquote(name).decode('utf-8')))
-        post = BM.BlogPost.query.get(slug=slug, app_config_id=c.app.config._id)
-        if post is None:
-            raise exc.HTTPNotFound()
-        return PostController(post), rest
-
-class PostController(BaseController):
-
-    def __init__(self, post):
-        self.post = post
-        setattr(self, 'feed.atom', self.feed)
-        setattr(self, 'feed.rss', self.feed)
-
-    def _check_security(self):
-        require_access(self.post, 'read')
-
-    @expose('jinja:forgeblog:templates/blog/post.html')
-    @with_trailing_slash
-    @validate(dict(page=validators.Int(if_empty=0),
-                   limit=validators.Int(if_empty=25)))
-    def index(self, page=0, limit=25, **kw):
-        if self.post.state == 'draft':
-            require_access(self.post, 'write')
-        c.form = W.view_post_form
-        c.subscribe_form = W.subscribe_form
-        c.thread = W.thread
-        post_count = self.post.discussion_thread.post_count
-        limit, page = h.paging_sanitizer(limit, page, post_count)
-        version = kw.pop('version', None)
-        post = self._get_version(version)
-        base_post = self.post
-        return dict(post=post, base_post=base_post,
-                    page=page, limit=limit, count=post_count)
-
-    @expose('jinja:forgeblog:templates/blog/edit_post.html')
-    @without_trailing_slash
-    def edit(self, **kw):
-        require_access(self.post, 'write')
-        c.form = W.edit_post_form
-        c.attachment_add = W.attachment_add
-        c.attachment_list = W.attachment_list
-        c.label_edit = W.label_edit
-        return dict(post=self.post)
-
-    @without_trailing_slash
-    @expose('jinja:forgeblog:templates/blog/post_history.html')
-    def history(self, **kw):
-        posts = self.post.history()
-        return dict(title=self.post.title, posts=posts)
-
-    @without_trailing_slash
-    @expose('jinja:forgeblog:templates/blog/post_diff.html')
-    def diff(self, v1, v2, **kw):
-        p1 = self._get_version(int(v1))
-        p2 = self._get_version(int(v2))
-        result = h.diff_text(p1.text, p2.text)
-        return dict(p1=p1, p2=p2, edits=result)
-
-    @expose()
-    @require_post()
-    @validate(form=W.edit_post_form, error_handler=edit)
-    @without_trailing_slash
-    def save(self, delete=None, **kw):
-        require_access(self.post, 'write')
-        if delete:
-            self.post.delete()
-            flash('Post deleted', 'info')
-            redirect(h.really_unicode(c.app.url).encode('utf-8'))
-        for k,v in kw.iteritems():
-            setattr(self.post, k, v)
-        self.post.commit()
-        redirect('.')
-
-    @without_trailing_slash
-    @require_post()
-    @expose()
-    def revert(self, version, **kw):
-        require_access(self.post, 'write')
-        orig = self._get_version(version)
-        if orig:
-            self.post.text = orig.text
-        self.post.commit()
-        redirect('.')
-
-    @expose()
-    @validate(W.subscribe_form)
-    def subscribe(self, subscribe=None, unsubscribe=None, **kw):
-        if subscribe:
-            self.post.subscribe(type='direct')
-        elif unsubscribe:
-            self.post.unsubscribe()
-        redirect(h.really_unicode(request.referer).encode('utf-8'))
-
-    @without_trailing_slash
-    @expose()
-    @validate(dict(
-            since=h.DateTimeConverter(if_empty=None, if_invalid=None),
-            until=h.DateTimeConverter(if_empty=None, if_invalid=None),
-            offset=validators.Int(if_empty=None),
-            limit=validators.Int(if_empty=None)))
-    def feed(self, since=None, until=None, offset=None, limit=None, **kw):
-        if request.environ['PATH_INFO'].endswith('.atom'):
-            feed_type = 'atom'
-        else:
-            feed_type = 'rss'
-        feed = M.Feed.feed(
-            dict(ref_id=self.post.index_id()),
-            feed_type,
-            'Recent changes to %s' % self.post.title,
-            self.post.url(),
-            'Recent changes to %s' % self.post.title,
-            since, until, offset, limit)
-        response.headers['Content-Type'] = ''
-        response.content_type = 'application/xml'
-        return feed.writeString('utf-8')
-
-    def _get_version(self, version):
-        if not version: return self.post
-        try:
-            return self.post.get_version(version)
-        except ValueError:
-            raise exc.HTTPNotFound()
-
-class BlogAdminController(DefaultAdminController):
-    def __init__(self, app):
-        self.app = app
-
-    @without_trailing_slash
-    @expose('jinja:forgeblog:templates/blog/admin_options.html')
-    def options(self):
-        return dict(app=self.app,
-                    allow_config=has_access(self.app, 'configure')())
-
-    @without_trailing_slash
-    @expose()
-    @require_post()
-    def set_options(self, show_discussion=False):
-        self.app.config.options['show_discussion'] = show_discussion and True or False
-        flash('Blog options updated')
-        redirect(h.really_unicode(c.project.url()+'admin/tools').encode('utf-8'))
-
-    @without_trailing_slash
-    @expose('jinja:forgeblog:templates/blog/admin_exfeed.html')
-    def exfeed(self):
-        #self.app.external_feeds_list = ['feed1', 'feed2']
-        #log.info("EXFEED: %s" % self.app.external_feeds_list)
-        feeds_list = []
-        for feed in self.app.external_feeds_list:
-            feeds_list.append(feed)
-        return dict(app=self.app,
-                    feeds_list=feeds_list,
-                    allow_config=has_access(self.app, 'configure')())
-
-    @without_trailing_slash
-    @expose()
-    @require_post()
-    def set_exfeed(self, new_exfeed=None, **kw):
-        exfeed_val = kw.get('exfeed', [])
-        if type(exfeed_val) == unicode:
-            tmp_exfeed_list = []
-            tmp_exfeed_list.append(exfeed_val)
-        else:
-            tmp_exfeed_list = exfeed_val
-
-        if new_exfeed is not None and new_exfeed != '':
-            tmp_exfeed_list.append(new_exfeed)
-
-        exfeed_list = []
-        invalid_list = []
-        v = validators.URL()
-        for link in tmp_exfeed_list:
-            try:
-                v.to_python(link)
-                exfeed_list.append(link)
-            except formencode.api.Invalid:
-                invalid_list.append(link)
-
-        self.app.external_feeds_list = exfeed_list
-        flash('External feeds updated')
-        if len(invalid_list) > 0:
-            flash('Invalid link(s): %s' % ','.join(link for link in invalid_list), 'error')
-
-        redirect(c.project.url()+'admin/tools')
+        return 'asf'
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c58db09e/ForgeBlog/forgeblog/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/functional/test_root.py b/ForgeBlog/forgeblog/tests/functional/test_root.py
index 84520f7..7f0047b 100644
--- a/ForgeBlog/forgeblog/tests/functional/test_root.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_root.py
@@ -14,6 +14,7 @@ from allura import model as M
 # CommentController methods exposed:
 #     reply, delete
 
+
 class TestRootController(TestController):
 
     def _post(self, slug='', **kw):
@@ -46,6 +47,10 @@ class TestRootController(TestController):
         assert create_activity.call_count == 1
         assert create_activity.call_args[0][1] == 'renamed'
 
+    def test_simple(self):
+        response = self.app.get('/blog/')
+        assert False
+
     def test_root_index(self):
         self._post()
         d = self._blog_date()
@@ -79,7 +84,7 @@ class TestRootController(TestController):
 
     def test_validation(self):
         r = self._post(title='')
-        assert 'You must provide a Title' in r
+        assert 'You must provide a Title' in r, r
 
     def test_root_new_search(self):
         self._post()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c58db09e/ForgeBlog/forgeblog/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/test_commands.py b/ForgeBlog/forgeblog/tests/test_commands.py
index 6b4b44c..8757cbd 100644
--- a/ForgeBlog/forgeblog/tests/test_commands.py
+++ b/ForgeBlog/forgeblog/tests/test_commands.py
@@ -1,178 +1 @@
-from datetime import datetime, timedelta
-import pylons
-pylons.c = pylons.tmpl_context
-pylons.g = pylons.app_globals
-from pylons import c, g
-from datadiff.tools import assert_equal
-
-from html2text import html2text
-
-from ming.orm.ormsession import ThreadLocalORMSession
-
-from alluratest.controller import setup_basic_test, setup_global_objects
-from allura import model as M
-from allura.lib import security
-from allura.lib import helpers as h
-from forgeblog import model as BM
 from forgeblog.command import rssfeeds
-
-import mock
-
-
-test_config = 'test.ini#main'
-
-def setUp():
-    setup_basic_test()
-    setup_global_objects()
-
-def _mock_feed(*entries):
-    class attrdict(dict):
-        def __getattr__(self, name):
-            return self[name]
-
-    feed = mock.Mock()
-    feed.bozo = False
-    feed.entries = []
-    for e in entries:
-        _mock_feed.i += 1
-        entry = attrdict(
-            content_type='text/plain',
-            title='Default Title %d' % _mock_feed.i,
-            subtitle='',
-            summary='',
-            link='http://example.com/',
-            updated=datetime.utcnow()+timedelta(days=_mock_feed.i - 100))
-        entry.update(e)
-        entry['updated_parsed'] = entry['updated'].timetuple()
-        if 'content' in entry:
-            entry['content'] = [attrdict(type=entry['content_type'], value=entry['content'])]
-        feed.entries.append(entry)
-
-    return feed
-_mock_feed.i = 0
-
-@mock.patch.object(rssfeeds.feedparser, 'parse')
-def test_pull_rss_feeds(parsefeed):
-    parsefeed.return_value = _mock_feed(
-        dict(title='Test', subtitle='test', summary='This is a test'),
-        dict(content_type='text/plain', content='Test feed'),
-        dict(content_type='text/html', content=
-                "<p>1. foo</p>\n"
-                "\n"
-                "<p>\n"
-                "#foo bar <a href='baz'>baz</a>\n"
-                "foo bar\n"
-                "</p>\n"
-                "\n"
-                "<p>#foo bar <a href='baz'>\n"
-                "baz\n"
-                "</a></p>\n"
-            ),
-    )
-
-    base_app =  M.AppConfig.query.find().all()[0]
-    tmp_app = M.AppConfig(tool_name=u'Blog', discussion_id=base_app.discussion_id,
-                          project_id=base_app.project_id,
-                          options={u'ordinal': 0, u'show_right_bar': True,
-                                    u'project_name': base_app.project.name,
-                                    u'mount_point': u'blog',
-                                    u'mount_label': u'Blog'})
-    new_external_feeds = ['http://example.com/news/feed/']
-    BM.Globals(app_config_id=tmp_app._id, external_feeds=new_external_feeds)
-    ThreadLocalORMSession.flush_all()
-
-    cmd = rssfeeds.RssFeedsCommand('pull-rss-feeds')
-    cmd.run([test_config, '-a', tmp_app._id])
-    cmd.command()
-    parsefeed.assert_called_with('http://example.com/news/feed/')
-    posts = BM.BlogPost.query.find({'app_config_id': tmp_app._id}).sort('timestamp', 1)
-    assert_equal(posts.count(), 3)
-    posts = posts.all()
-    assert_equal(posts[0].title, 'Test')
-    assert_equal(posts[0].text, 'This is a test [link](http://example.com/)')
-    assert_equal(posts[1].title, 'Default Title 2')
-    assert_equal(posts[1].text, 'Test feed [link](http://example.com/)')
-    assert_equal(posts[2].title, 'Default Title 3')
-    assert_equal(posts[2].text, "\n".join([
-       r"1\. foo",
-        "",
-       r"\#foo bar [baz](baz) foo bar ",
-        "",
-       r"\#foo bar [ baz ](baz)",
-        " [link](http://example.com/)",
-    ]))
-
-def test_plaintext_preprocessor():
-    text = html2text(
-        "[plain]1. foo[/plain]\n"
-        "\n"
-        "[plain]#foo bar [/plain]<a href='baz'>[plain]baz[/plain]</a>\n"
-        "[plain]foo bar[/plain]\n"
-        "\n"
-        "[plain]#foo bar [/plain]<a href='baz'>\n"
-        "[plain]baz[/plain]\n"
-        "</a>\n"
-    )
-    html = g.markdown.convert(text)
-    assert_equal(html,
-        '<div class="markdown_content"><p>1. foo '
-        '#foo bar <a class="" href="../baz">baz</a> foo bar '
-        '#foo bar <a class="" href="../baz"> baz </a></p></div>'
-    )
-
-def test_plaintext_preprocessor_wrapped():
-    text = html2text(
-        "<p>[plain]1. foo[/plain]</p>\n"
-        "\n"
-        "<p>\n"
-        "[plain]#foo bar [/plain]<a href='baz'>[plain]baz[/plain]</a>\n"
-        "[plain]foo bar[/plain]\n"
-        "</p>\n"
-        "\n"
-        "<p>[plain]#foo bar [/plain]<a href='baz'>\n"
-        "[plain]baz[/plain]\n"
-        "</a></p>\n"
-    )
-    html = g.markdown.convert(text)
-    assert_equal(html,
-        '<div class="markdown_content"><p>1. foo</p>\n'
-        '<p>#foo bar <a class="" href="../baz">baz</a> foo bar </p>\n'
-        '<p>#foo bar <a class="" href="../baz"> baz </a></p></div>'
-    )
-
-
-def test_plain2markdown():
-    text = '''paragraph
-
-    4 spaces before this
-
-    *blah*
-
-here's a <tag> that should be <b>preserved</b>
-Literal &gt; &Ograve; &frac14; &amp; &#38; &#x123F;
-M & Ms - doesn't get escaped
-http://blah.com/?x=y&a=b - not escaped either
-'''
-
-    expected = '''paragraph
-
-4 spaces before this
-
-\*blah\*
-
-here's a &lt;tag&gt; that should be &lt;b&gt;preserved&lt;/b&gt;
-Literal &amp;gt; &amp;Ograve; &amp;frac14; &amp;amp; &amp;\#38; &amp;\#x123F;
-M & Ms - doesn't get escaped
-http://blah.com/?x=y&a=b - not escaped either
-'''
-    # note: the \# isn't necessary it could be just # but that's the way
-    # html2text escapes all #s currently.  The extra escaping of \# ends up
-    # being ok though when rendered
-
-    assert_equal(rssfeeds.plain2markdown(text), expected)
-
-    assert_equal(rssfeeds.plain2markdown('a foo  bar\n\n    code here?', preserve_multiple_spaces=True),
-                'a foo&nbsp; bar\n\n&nbsp;&nbsp;&nbsp; code here?')
-
-    assert_equal(rssfeeds.plain2markdown('\ttab before (stuff)', preserve_multiple_spaces=True),
-                 '&nbsp;&nbsp;&nbsp; tab before \(stuff\)')
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c58db09e/run_tests
----------------------------------------------------------------------
diff --git a/run_tests b/run_tests
index a37f012..a7b426a 100755
--- a/run_tests
+++ b/run_tests
@@ -11,7 +11,6 @@ fi
 if [ "$TEST_MODULES"  == "" ]; then
     TEST_MODULES="\
     AlluraTesting \
-    Allura \
     ForgeBlog \
     ForgeLink \
     ForgeChat \


Mime
View raw message