You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/04/26 17:34:19 UTC
[1/9] git commit: Use custom Mock since mock lib not available
Updated Branches:
refs/heads/cj/5655 ab2236dc1 -> c40ddaf69 (forced update)
Use custom Mock since mock lib not available
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/fe2b2113
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/fe2b2113
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/fe2b2113
Branch: refs/heads/cj/5655
Commit: fe2b21132e35bc72032269728b044de26d003a3c
Parents: 77ebed3
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 16 02:47:46 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Apr 26 15:28:58 2013 +0000
----------------------------------------------------------------------
Allura/docs/conf.py | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fe2b2113/Allura/docs/conf.py
----------------------------------------------------------------------
diff --git a/Allura/docs/conf.py b/Allura/docs/conf.py
index 5f2d6cb..81c0e1f 100644
--- a/Allura/docs/conf.py
+++ b/Allura/docs/conf.py
@@ -29,14 +29,31 @@
# serve to show the default.
import sys, os
-import mock
+
+class Mock(object):
+ def __init__(self, *args, **kwargs):
+ pass
+
+ def __call__(self, *args, **kwargs):
+ return Mock()
+
+ @classmethod
+ def __getattr__(cls, name):
+ if name in ('__file__', '__path__'):
+ return '/dev/null'
+ elif name[0] == name[0].upper():
+ mockType = type(name, (), {})
+ mockType.__module__ = __name__
+ return mockType
+ else:
+ return Mock()
MOCK_MODULES = ['matplotlib', 'matplotlib.axes',
'matplotlib.backends', 'matplotlib.backends.backend_agg',
'matplotlib.figure', 'matplotlib.patches']
for mod_name in MOCK_MODULES:
- sys.modules[mod_name] = mock.Mock()
+ sys.modules[mod_name] = Mock()
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
[8/9] git commit: [#5655] Refactored site_stats and added ticket and
post 24hr stats
Posted by jo...@apache.org.
[#5655] Refactored site_stats and added ticket and post 24hr stats
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7225f737
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7225f737
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7225f737
Branch: refs/heads/cj/5655
Commit: 7225f73733b27e283982bf0975afe4d852c923b7
Parents: 68a3547
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 24 22:30:06 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Apr 26 15:33:52 2013 +0000
----------------------------------------------------------------------
Allura/allura/controllers/rest.py | 11 +++++++----
ForgeDiscussion/forgediscussion/site_stats.py | 8 ++++++++
ForgeDiscussion/setup.py | 3 +++
ForgeTracker/forgetracker/site_stats.py | 10 ++++++++++
ForgeTracker/setup.py | 3 +++
5 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7225f737/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 0d519cc..70e3ac7 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -62,10 +62,13 @@ class RestController(object):
@expose('json:')
def index(self, **kw):
- provider = g.entry_points['site_stats'].get('provider')
- if provider:
- return provider()
- return dict()
+ summary = dict()
+ stats = dict()
+ for stat, provider in g.entry_points['site_stats'].iteritems():
+ stats[stat] = provider()
+ if stats:
+ summary['site_stats'] = stats
+ return summary
@expose()
def _lookup(self, name, *remainder):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7225f737/ForgeDiscussion/forgediscussion/site_stats.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/site_stats.py b/ForgeDiscussion/forgediscussion/site_stats.py
new file mode 100644
index 0000000..e76201d
--- /dev/null
+++ b/ForgeDiscussion/forgediscussion/site_stats.py
@@ -0,0 +1,8 @@
+from datetime import datetime, timedelta
+
+from . import model as DM
+
+
+def posts_24hr():
+ window = datetime.utcnow() - timedelta(hours=24)
+ return DM.ForumPost.query.find({'timestamp': {'$gte': window}}).count()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7225f737/ForgeDiscussion/setup.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/setup.py b/ForgeDiscussion/setup.py
index 5c58b7a..812c8a0 100644
--- a/ForgeDiscussion/setup.py
+++ b/ForgeDiscussion/setup.py
@@ -44,5 +44,8 @@ setup(name='ForgeDiscussion',
# -*- Entry points: -*-
[allura]
Discussion=forgediscussion.forum_main:ForgeDiscussionApp
+
+ [allura.site_stats]
+ posts_24hr=forgediscussion.site_stats:posts_24hr
""",
)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7225f737/ForgeTracker/forgetracker/site_stats.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/site_stats.py b/ForgeTracker/forgetracker/site_stats.py
new file mode 100644
index 0000000..e0baa63
--- /dev/null
+++ b/ForgeTracker/forgetracker/site_stats.py
@@ -0,0 +1,10 @@
+from datetime import datetime, timedelta
+
+from bson import ObjectId
+
+from . import model as TM
+
+
+def tickets_stats_24hr():
+ window = datetime.utcnow() - timedelta(hours=24)
+ return TM.Ticket.query.find({'_id': {'$gte': ObjectId.from_datetime(window)}}).count()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7225f737/ForgeTracker/setup.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/setup.py b/ForgeTracker/setup.py
index 57e5d45..1934cc2 100644
--- a/ForgeTracker/setup.py
+++ b/ForgeTracker/setup.py
@@ -43,6 +43,9 @@ setup(name='ForgeTracker',
[allura]
Tickets=forgetracker.tracker_main:ForgeTrackerApp
+ [allura.site_stats]
+ tickets_24hr=forgetracker.site_stats:tickets_stats_24hr
+
[easy_widgets.resources]
ew_resources=forgetracker.config.resources:register_ew_resources
[3/9] git commit: Getting started with sphinx api docs
Posted by jo...@apache.org.
Getting started with sphinx api docs
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/670d9624
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/670d9624
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/670d9624
Branch: refs/heads/cj/5655
Commit: 670d96245626262a06164ba526c9c2ea994a8814
Parents: b9aaa61
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Fri Apr 12 22:47:06 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Apr 26 15:28:58 2013 +0000
----------------------------------------------------------------------
Allura/allura/app.py | 8 +++++++-
Allura/docs/api/app.rst | 11 +++++++++++
Allura/docs/index.rst | 9 +++++++++
3 files changed, 27 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/670d9624/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 18dbf59..b89285e 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -208,7 +208,13 @@ class Application(object):
return False
def is_visible_to(self, user):
- '''Whether the user can view the app.'''
+ """Return whether ``user`` can view this app.
+
+ :param user: user to check
+ :type user: :class:`allura.model.User` instance
+ :rtype: bool
+
+ """
return has_access(self, 'read')(user=user)
def subscribe_admins(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/670d9624/Allura/docs/api/app.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/api/app.rst b/Allura/docs/api/app.rst
new file mode 100644
index 0000000..688a8fa
--- /dev/null
+++ b/Allura/docs/api/app.rst
@@ -0,0 +1,11 @@
+.. _app_module:
+
+:mod:`allura.app`
+--------------------------------
+
+.. automodule:: allura.app
+
+ .. autoclass:: Application
+ :members:
+ :inherited-members:
+ :undoc-members:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/670d9624/Allura/docs/index.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/index.rst b/Allura/docs/index.rst
index ea20734..5063dac 100644
--- a/Allura/docs/index.rst
+++ b/Allura/docs/index.rst
@@ -58,6 +58,15 @@ Inside the Platform Components
guides/email
guides/permissions
+API Documentation
+==================
+
+.. toctree::
+ :maxdepth: 1
+ :glob:
+
+ api/*
+
Frequently Asked Questions
=====================================================================
.. toctree::
[4/9] git commit: For consistency
Posted by jo...@apache.org.
For consistency
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c0865029
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c0865029
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c0865029
Branch: refs/heads/cj/5655
Commit: c08650296af6360c34613fe34eb74bdcabc4e806
Parents: b8de746
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Wed Apr 24 16:45:22 2013 -0400
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Apr 26 15:28:59 2013 +0000
----------------------------------------------------------------------
Allura/allura/app.py | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c0865029/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 5eb64c6..bf874bf 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -324,8 +324,7 @@ class Application(object):
return ""
def admin_menu(self, force_options=False):
- """
- Return the admin menu for this Application.
+ """Return the admin menu for this Application.
Default implementation will return a menu with up to 3 links:
[5/9] git commit: Continue documenting allura.app.Application
Posted by jo...@apache.org.
Continue documenting allura.app.Application
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b71e5636
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b71e5636
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b71e5636
Branch: refs/heads/cj/5655
Commit: b71e56361c4cbd9003ac7e67461fb0e2d6e4c4d4
Parents: fe2b211
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Wed Apr 24 00:49:58 2013 -0400
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Apr 26 15:28:59 2013 +0000
----------------------------------------------------------------------
Allura/allura/app.py | 48 ++++++++++++++++++++++++++++++++++++-----
Allura/docs/api/app.rst | 2 -
Allura/docs/index.rst | 4 +-
3 files changed, 44 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b71e5636/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index b89285e..05ad7d8 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -204,13 +204,19 @@ class Application(object):
return ''
def has_access(self, user, topic):
- '''Whether the user has access to send email to the given topic'''
+ """Return True if ``user`` can send email to ``topic``.
+ Default is False.
+
+ :type user: :class:`allura.model.User` instance
+ :type topic: str
+ :rtype: bool
+
+ """
return False
def is_visible_to(self, user):
- """Return whether ``user`` can view this app.
+ """Return True if ``user`` can view this app.
- :param user: user to check
:type user: :class:`allura.model.User` instance
:rtype: bool
@@ -235,7 +241,12 @@ class Application(object):
@classmethod
def default_options(cls):
- ":return: the default config options"
+ """Return a ``(name, default value)`` mapping of this Application's
+ :class:`config_options <ConfigOption>`.
+
+ :rtype: dict
+
+ """
return dict(
(co.name, co.default)
for co in cls.config_options)
@@ -297,8 +308,23 @@ class Application(object):
def admin_menu(self, force_options=False):
"""
- Apps may override this to provide additional admin menu items
+ Return the admin menu for this Application.
+
+ Default implementation will return a menu with up to 3 links:
+
+ - 'Permissions', if the current user has admin access to the
+ project in which this Application is installed
+ - 'Options', if this Application has custom options, or
+ ``force_options`` is True
+ - 'Label', for editing this Application's label
+
+ Subclasses should override this method to provide additional admin
+ menu items.
+
+ :param force_options: always include an 'Options' link in the menu,
+ even if this Application has no custom options
:return: a list of :class:`SitemapEntries <allura.app.SitemapEntry>`
+
"""
admin_url = c.project.url()+'admin/'+self.config.options.mount_point+'/'
links = []
@@ -310,7 +336,17 @@ class Application(object):
return links
def handle_message(self, topic, message):
- '''Handle incoming email msgs addressed to this tool'''
+ """Handle incoming email msgs addressed to this tool.
+ Default is a no-op.
+
+ :param topic: portion of destination email address preceeding the '@'
+ :type topic: str
+ :param message: parsed email message
+ :type message: dict - result of
+ :func:`allura.lib.mail_util.parse_message`
+ :rtype: None
+
+ """
pass
def handle_artifact_message(self, artifact, message):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b71e5636/Allura/docs/api/app.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/api/app.rst b/Allura/docs/api/app.rst
index 688a8fa..7fcd90b 100644
--- a/Allura/docs/api/app.rst
+++ b/Allura/docs/api/app.rst
@@ -7,5 +7,3 @@
.. autoclass:: Application
:members:
- :inherited-members:
- :undoc-members:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b71e5636/Allura/docs/index.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/index.rst b/Allura/docs/index.rst
index 5063dac..56b1b52 100644
--- a/Allura/docs/index.rst
+++ b/Allura/docs/index.rst
@@ -63,9 +63,9 @@ API Documentation
.. toctree::
:maxdepth: 1
- :glob:
+ :glob:
- api/*
+ api/*
Frequently Asked Questions
=====================================================================
[2/9] git commit: Mock out matplotlib for readthedocs
Posted by jo...@apache.org.
Mock out matplotlib for readthedocs
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/77ebed31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/77ebed31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/77ebed31
Branch: refs/heads/cj/5655
Commit: 77ebed310b089a9da03a963f130502c715b2abfa
Parents: 670d962
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 16 02:40:48 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Apr 26 15:28:58 2013 +0000
----------------------------------------------------------------------
Allura/docs/conf.py | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/77ebed31/Allura/docs/conf.py
----------------------------------------------------------------------
diff --git a/Allura/docs/conf.py b/Allura/docs/conf.py
index cd227ca..5f2d6cb 100644
--- a/Allura/docs/conf.py
+++ b/Allura/docs/conf.py
@@ -29,6 +29,14 @@
# serve to show the default.
import sys, os
+import mock
+
+MOCK_MODULES = ['matplotlib', 'matplotlib.axes',
+ 'matplotlib.backends', 'matplotlib.backends.backend_agg',
+ 'matplotlib.figure', 'matplotlib.patches']
+
+for mod_name in MOCK_MODULES:
+ sys.modules[mod_name] = mock.Mock()
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -54,7 +62,7 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
-project = 'Apache Allura'
+project = 'Apache Allura (incubating)'
copyright = '2012-2013 The Apache Software Foundation'
# The version info for the project you're documenting, acts as replacement for
[6/9] git commit: Clean up cvar docstrings
Posted by jo...@apache.org.
Clean up cvar docstrings
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b8de7461
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b8de7461
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b8de7461
Branch: refs/heads/cj/5655
Commit: b8de74614fd49abe5235fb5645c0f7a00db52cde
Parents: b71e563
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Wed Apr 24 09:35:34 2013 -0400
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Apr 26 15:28:59 2013 +0000
----------------------------------------------------------------------
Allura/allura/app.py | 63 ++++++++++++++++++++++++++++----------------
1 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b8de7461/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 05ad7d8..5eb64c6 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -118,41 +118,58 @@ class SitemapEntry(object):
return self.url in request.upath_info or any([
url in request.upath_info for url in self.matching_urls])
+
class Application(object):
"""
The base Allura pluggable application
- After extending this, expose the app by adding an entry point in your setup.py:
+ After extending this, expose the app by adding an entry point in your
+ setup.py:
[allura]
myapp = foo.bar.baz:MyAppClass
- :var status: the status level of this app. 'production' apps are available to all projects
- :var bool searchable: toggle if the search box appears in the left menu
- :var permissions: a list of named permissions used by the app
- :var sitemap: a list of :class:`SitemapEntries <allura.app.SitemapEntry>` to create an app navigation.
- :var bool installable: toggle if the app can be installed in a project
- :var bool hidden: toggle if the app should be hidden from the list of tools
- :var tool_description: tool's description that will be displayed to forge users
- :var Controller self.root: the root Controller used for the app
- :var Controller self.api_root: a Controller used for API access at /rest/<neighborhood>/<project>/<app>/
- :var Controller self.admin: a Controller used in the admin interface
- :var icons: a dictionary mapping icon sizes to application-specific icons paths
+ :cvar str status: One of 'production', 'beta', 'alpha', or 'user'. By
+ default, only 'production' apps are installable in projects. Default
+ is 'production'.
+ :cvar bool searchable: If True, show search box in the left menu of this
+ Application. Default is True.
+ :cvar list permissions: Named permissions used by instances of this
+ Application. Default is [].
+ :cvar list sitemap: :class:`SitemapEntries <allura.app.SitemapEntry>`
+ used to create the Application's navigation in the left side bar.
+ Default is [].
+ :cvar bool installable: Default is True, Application can be installed in
+ projects.
+ :cvar bool hidden: Default is False, Application is not hidden from the
+ list of a project's installed tools.
+ :cvar str tool_description: Text description of this Application.
+ :cvar Controller root: Serves content at
+ /<neighborhood>/<project>/<app>/. Default is None - subclasses should
+ override.
+ :cvar Controller api_root: Serves API access at
+ /rest/<neighborhood>/<project>/<app>/. Default is None - subclasses
+ should override to expose API access to the Application.
+ :ivar Controller admin: Serves admin functions at
+ /<neighborhood>/<project>/<admin>/<app>/. Default is a
+ :class:`DefaultAdminController` instance.
+ :cvar dict icons: Mapping of icon sizes to application-specific icon paths.
+
"""
__version__ = None
config_options = [
ConfigOption('mount_point', str, 'app'),
ConfigOption('mount_label', str, 'app'),
- ConfigOption('ordinal', int, '0') ]
- status_map = [ 'production', 'beta', 'alpha', 'user' ]
- status='production'
- script_name=None
- root=None # root controller
- api_root=None
- permissions=[]
- sitemap = [ ]
- installable=True
+ ConfigOption('ordinal', int, '0')]
+ status_map = ['production', 'beta', 'alpha', 'user']
+ status = 'production'
+ script_name = None
+ root = None # root controller
+ api_root = None
+ permissions = []
+ sitemap = []
+ installable = True
searchable = False
DiscussionClass = model.Discussion
PostClass = model.Post
@@ -207,8 +224,8 @@ class Application(object):
"""Return True if ``user`` can send email to ``topic``.
Default is False.
- :type user: :class:`allura.model.User` instance
- :type topic: str
+ :param user: :class:`allura.model.User` instance
+ :param topic: str
:rtype: bool
"""
[9/9] git commit: [#5655] Added test for site_stats EP discovery
Posted by jo...@apache.org.
[#5655] Added test for site_stats EP discovery
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c40ddaf6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c40ddaf6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c40ddaf6
Branch: refs/heads/cj/5655
Commit: c40ddaf69d11d20955e78a1d2ba86c52861595a4
Parents: 7225f73
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Apr 26 15:28:09 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Apr 26 15:33:52 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_rest.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c40ddaf6/Allura/allura/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_rest.py b/Allura/allura/tests/functional/test_rest.py
index 68f769f..a08e8f7 100644
--- a/Allura/allura/tests/functional/test_rest.py
+++ b/Allura/allura/tests/functional/test_rest.py
@@ -19,7 +19,10 @@
from datetime import datetime, timedelta
+from pylons import app_globals as g
from nose.tools import assert_equal
+import mock
+import json
from allura.tests import decorators as td
from alluratest.controller import TestRestApiBase
@@ -96,3 +99,21 @@ class TestRestHome(TestRestApiBase):
self.app.get('/rest/p/test/wiki/Home/',
extra_environ={'username': 'test-user-0'},
status=401)
+
+ def test_index(self):
+ eps = {
+ 'site_stats': {
+ 'foo_24hr': lambda: 42,
+ 'bar_24hr': lambda: 84,
+ 'qux_24hr': lambda: 0,
+ },
+ }
+ with mock.patch.dict(g.entry_points, eps):
+ response = self.app.get('/rest/')
+ assert_equal(response.json, {
+ 'site_stats': {
+ 'foo_24hr': 42,
+ 'bar_24hr': 84,
+ 'qux_24hr': 0,
+ },
+ })
[7/9] git commit: [#5655] Added root REST view with hook for
providing site stats
Posted by jo...@apache.org.
[#5655] Added root REST view with hook for providing site stats
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/68a35476
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/68a35476
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/68a35476
Branch: refs/heads/cj/5655
Commit: 68a354766986384384d5ab5ee30ceb10f44ab04b
Parents: c086502
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Apr 22 23:29:12 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Apr 26 15:33:52 2013 +0000
----------------------------------------------------------------------
Allura/allura/controllers/rest.py | 9 ++++++++-
Allura/allura/lib/app_globals.py | 1 +
2 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68a35476/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index e7d11f9..0d519cc 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -23,7 +23,7 @@ import logging
import oauth2 as oauth
from webob import exc
from tg import expose, flash, redirect
-from pylons import tmpl_context as c
+from pylons import tmpl_context as c, app_globals as g
from pylons import request
from ming.orm import session
@@ -60,6 +60,13 @@ class RestController(object):
else:
return None
+ @expose('json:')
+ def index(self, **kw):
+ provider = g.entry_points['site_stats'].get('provider')
+ if provider:
+ return provider()
+ return dict()
+
@expose()
def _lookup(self, name, *remainder):
api_token = self._authenticate_request()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68a35476/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 3eb816b..e5b00c7 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -185,6 +185,7 @@ class Globals(object):
user_prefs=_cache_eps('allura.user_prefs'),
spam=_cache_eps('allura.spam'),
stats=_cache_eps('allura.stats'),
+ site_stats=_cache_eps('allura.site_stats'),
)
# Zarkov logger