You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/08/14 15:15:56 UTC
[1/4] git commit: [#4818] sort entry points for reliable ordering
Updated Branches:
refs/heads/master dfafc6251 -> c70060322
[#4818] sort entry points for reliable ordering
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c7006032
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c7006032
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c7006032
Branch: refs/heads/master
Commit: c70060322432813497d338c502d734eafe808bd4
Parents: c0dbb7f
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 9 21:47:00 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Wed Aug 14 13:12:13 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c7006032/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index 98a34c8..06aaec1 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -140,7 +140,8 @@ class AdminApp(Application):
links.append(None)
links.append(SitemapEntry('Help', nbhd_admin_url+ 'help/'))
- for name, admin_extension in g.entry_points['admin'].iteritems():
+ for ep_name in sorted(g.entry_points['admin'].keys()):
+ admin_extension = g.entry_points['admin'][ep_name]
admin_extension().update_project_sidebar_menu(links)
return links
@@ -156,7 +157,8 @@ class AdminExtensionLookup(object):
@expose()
def _lookup(self, name, *remainder):
- for ext_name, admin_extension in g.entry_points['admin'].iteritems():
+ for ep_name in sorted(g.entry_points['admin'].keys()):
+ admin_extension = g.entry_points['admin'][ep_name]
controller = admin_extension().project_admin_controllers.get(name)
if controller:
return controller(), remainder
[3/4] git commit: [#4818] don't error if tool doesn't exist any more
Posted by tv...@apache.org.
[#4818] don't error if tool doesn't exist any more
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c0dbb7fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c0dbb7fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c0dbb7fe
Branch: refs/heads/master
Commit: c0dbb7fe53a0fdc244cb6c9904533564dd7e6559
Parents: df942cb
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 9 20:01:21 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Wed Aug 14 13:12:13 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c0dbb7fe/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index 92efacb..98a34c8 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -153,7 +153,7 @@ class AdminApp(Application):
class AdminExtensionLookup(object):
-
+
@expose()
def _lookup(self, name, *remainder):
for ext_name, admin_extension in g.entry_points['admin'].iteritems():
@@ -177,8 +177,11 @@ class ProjectAdminController(BaseController):
@with_trailing_slash
@expose('jinja:allura.ext.admin:templates/project_admin.html')
def index(self, **kw):
- scm_tools = [tool for tool in c.project.app_configs if issubclass(
- g.entry_points["tool"][tool.tool_name], RepositoryApp)]
+ scm_tools = []
+ for tool in c.project.app_configs:
+ app = g.entry_points["tool"].get(tool.tool_name)
+ if app and issubclass(app, RepositoryApp):
+ scm_tools.append(tool)
return dict(scm_tools=scm_tools)
@without_trailing_slash
[2/4] git commit: [#4818] add documentation for extensions
Posted by tv...@apache.org.
[#4818] add documentation for extensions
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/df942cb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/df942cb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/df942cb2
Branch: refs/heads/master
Commit: df942cb262f9b541dd6235420e3a39c1398e6693
Parents: 5f836ba
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 9 19:41:28 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Wed Aug 14 13:12:13 2013 +0000
----------------------------------------------------------------------
Allura/allura/app.py | 2 +-
Allura/allura/lib/plugin.py | 10 +++---
Allura/docs/api/app.rst | 13 +-------
Allura/docs/api/lib/plugin.rst | 24 ++++++++++++++
Allura/docs/api/lib/spam.rst | 24 ++++++++++++++
Allura/docs/extending.rst | 55 +++++++++++++++++++++++++++++++++
Allura/docs/guides/message_bus.rst | 4 ++-
Allura/docs/index.rst | 3 +-
8 files changed, 115 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index c1d2517..5ac11f2 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -164,7 +164,7 @@ class Application(object):
The base Allura pluggable application
After extending this, expose the app by adding an entry point in your
- setup.py:
+ setup.py::
[allura]
myapp = foo.bar.baz:MyAppClass
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index f972c26..f600363 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -56,12 +56,12 @@ class AuthenticationProvider(object):
'''
An interface to provide authentication services for Allura.
- To use a new provider, expose an entry point in setup.py:
+ To use a new provider, expose an entry point in setup.py::
[allura.auth]
myprovider = foo.bar:MyAuthProvider
- Then in your .ini file, set auth.method=myprovider
+ Then in your .ini file, set ``auth.method=myprovider``
'''
def __init__(self, request):
@@ -346,7 +346,7 @@ class ProjectRegistrationProvider(object):
and the default. Extend this class with your own if you need to add more
functionality.
- To use a new provider, expose an entry point in setup.py:
+ To use a new provider, expose an entry point in setup.py::
[allura.project_registration]
myprovider = foo.bar:MyAuthProvider
@@ -625,7 +625,7 @@ class ThemeProvider(object):
and the default. Extend this class with your own if you need to add more
functionality.
- To use a new provider, expose an entry point in setup.py:
+ To use a new provider, expose an entry point in setup.py::
[allura.theme]
myprovider = foo.bar:MyThemeProvider
@@ -855,7 +855,7 @@ class UserPreferencesProvider(object):
'''
An interface for user preferences, like display_name and email_address
- To use a new provider, expose an entry point in setup.py:
+ To use a new provider, expose an entry point in setup.py::
[allura.user_prefs]
myprefs = foo.bar:MyUserPrefProvider
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/docs/api/app.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/api/app.rst b/Allura/docs/api/app.rst
index 491d0b4..f99a0c2 100644
--- a/Allura/docs/api/app.rst
+++ b/Allura/docs/api/app.rst
@@ -22,15 +22,4 @@
.. automodule:: allura.app
- .. autoclass:: Application
- :members:
-
- .. autoclass:: ConfigOption
- :members:
-
- .. autoclass:: DefaultAdminController
- :members:
-
- .. autoclass:: SitemapEntry
- :members:
-
+ :members:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/docs/api/lib/plugin.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/api/lib/plugin.rst b/Allura/docs/api/lib/plugin.rst
new file mode 100644
index 0000000..77e619b
--- /dev/null
+++ b/Allura/docs/api/lib/plugin.rst
@@ -0,0 +1,24 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+.. _plugin_module:
+
+:mod:`allura.lib.plugin`
+-------------------------------------
+
+.. automodule:: allura.lib.plugin
+ :members:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/docs/api/lib/spam.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/api/lib/spam.rst b/Allura/docs/api/lib/spam.rst
new file mode 100644
index 0000000..b9558a3
--- /dev/null
+++ b/Allura/docs/api/lib/spam.rst
@@ -0,0 +1,24 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+.. _spam_module:
+
+:mod:`allura.lib.spam`
+-------------------------------------
+
+.. automodule:: allura.lib.spam
+ :members:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/docs/extending.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/extending.rst b/Allura/docs/extending.rst
new file mode 100644
index 0000000..a430202
--- /dev/null
+++ b/Allura/docs/extending.rst
@@ -0,0 +1,55 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+Extending Allura with Entry Points
+===================================
+
+There are many extension points to extending Allura. They all make themselves
+known to Allura via python entry points defined in ``setup.py``. Many are then
+available immediately. Others, such as authentication providers or themes, need
+to be specified in your ``.ini`` file, since you may only have one enabled at a time.
+
+The available extension points for Allura are:
+
+* :class:`allura.app.Application` (aka tool) and :class:`allura.app.Artifact`
+* :class:`allura.lib.plugin.ThemeProvider`
+* :class:`allura.lib.plugin.ProjectRegistrationProvider`
+* :class:`allura.lib.plugin.AuthenticationProvider`
+* :class:`allura.lib.plugin.UserPreferencesProvider`
+* :class:`allura.lib.plugin.AdminExtension`
+* :class:`allura.lib.spam.SpamFilter`
+* ``site_stats`` in the root API data. Docs in :class:`allura.controllers.rest.RestController`
+* :mod:`allura.lib.package_path_loader` (for overriding templates)
+
+A listing of available 3rd-party extensions is at https://sourceforge.net/p/allura/wiki/Extensions/
+
+Other entry points are used to provider ``paster`` commands and ``easy_widget`` configuration.
+
+
+Event Handlers
+==============
+
+Another way to extend Allura is set up event handlers to respond to Allura events.
+There is documentation and examples at :ref:`events`.
+
+The events that allura publishes are:
+
+* project_created
+* project_updated
+* repo_cloned
+* repo_refreshed
+* repo_clone_task_failed
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/docs/guides/message_bus.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/guides/message_bus.rst b/Allura/docs/guides/message_bus.rst
index f8285e1..11067c9 100644
--- a/Allura/docs/guides/message_bus.rst
+++ b/Allura/docs/guides/message_bus.rst
@@ -61,6 +61,8 @@ well::
commit()
+.. _events:
+
Events
-------------------
@@ -82,7 +84,7 @@ Under the covers, this is scheduling an `event` task that calls all the handlers
for a particular named event. Note that you can pass arguments (\*args, and
\*\*kwargs) to event handlers just like you do to tasks, with the exception that
the topic name (above, this would be 'project_updated') is always the first
-parameter passed to the event handler.
+parameter passed to the event handler.
Running the Task Daemon
----------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df942cb2/Allura/docs/index.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/index.rst b/Allura/docs/index.rst
index 56b1b52..877b98d 100644
--- a/Allura/docs/index.rst
+++ b/Allura/docs/index.rst
@@ -57,12 +57,13 @@ Inside the Platform Components
guides/message_bus
guides/email
guides/permissions
+ extending
API Documentation
==================
.. toctree::
- :maxdepth: 1
+ :maxdepth: 2
:glob:
api/*
[4/4] git commit: [#4818] add admin extensions
Posted by tv...@apache.org.
[#4818] add admin extensions
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5f836baa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5f836baa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5f836baa
Branch: refs/heads/master
Commit: 5f836baa5b741bb24175233b90276df90a7fa11b
Parents: dfafc62
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 9 19:41:07 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Wed Aug 14 13:12:13 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 17 ++++++++++
Allura/allura/lib/app_globals.py | 1 +
Allura/allura/lib/plugin.py | 32 +++++++++++++++++++
Allura/allura/tests/functional/test_admin.py | 39 +++++++++++++++++++++++
4 files changed, 89 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f836baa/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index f8c8983..92efacb 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -139,6 +139,10 @@ class AdminApp(Application):
links.append(SitemapEntry('Statistics', nbhd_admin_url+ 'stats/'))
links.append(None)
links.append(SitemapEntry('Help', nbhd_admin_url+ 'help/'))
+
+ for name, admin_extension in g.entry_points['admin'].iteritems():
+ admin_extension().update_project_sidebar_menu(links)
+
return links
def admin_menu(self):
@@ -147,6 +151,18 @@ class AdminApp(Application):
def install(self, project):
pass
+
+class AdminExtensionLookup(object):
+
+ @expose()
+ def _lookup(self, name, *remainder):
+ for ext_name, admin_extension in g.entry_points['admin'].iteritems():
+ controller = admin_extension().project_admin_controllers.get(name)
+ if controller:
+ return controller(), remainder
+ raise exc.HTTPNotFound, name
+
+
class ProjectAdminController(BaseController):
def _check_security(self):
@@ -156,6 +172,7 @@ class ProjectAdminController(BaseController):
self.permissions = PermissionsController()
self.groups = GroupsController()
self.audit = AuditController()
+ self.ext = AdminExtensionLookup()
@with_trailing_slash
@expose('jinja:allura.ext.admin:templates/project_admin.html')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f836baa/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index bdcacf7..7f45f69 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -197,6 +197,7 @@ class Globals(object):
spam=_cache_eps('allura.spam'),
stats=_cache_eps('allura.stats'),
site_stats=_cache_eps('allura.site_stats'),
+ admin=_cache_eps('allura.admin'),
)
# Zarkov logger
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f836baa/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 4afd9fc..f972c26 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -915,3 +915,35 @@ class LocalUserPreferencesProvider(UserPreferencesProvider):
users = M.User.query.find(dict(
display_name=name_regex)).sort('username').all()
return users
+
+
+class AdminExtension(object):
+ """
+ A base class for extending the admin areas in Allura.
+
+ After extending this, expose the app by adding an entry point in your
+ setup.py::
+
+ [allura.admin]
+ myadmin = foo.bar.baz:MyCustomAdmin
+
+ :ivar dict project_admin_controllers: Mapping of str (url component) to
+ Controllers. Can be implemented as a ``@property`` function. The str
+ url components will be mounted at /p/someproject/admin/ext/STR/ and will
+ invoke the Controller.
+ """
+
+ project_admin_controllers = {}
+
+ def update_project_sidebar_menu(self, sidebar_links):
+ """
+ Implement this function to modify the project sidebar.
+ Check `c.project` if you want to limit when this displays
+ (e.g. nbhd project, subproject, etc)
+
+ :param sidebar_links: project admin side bar links
+ :type sidebar_links: list of :class:`allura.app.SitemapEntry`
+
+ :rtype: ``None``
+ """
+ pass
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f836baa/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 7d630c9..adeb71b 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -24,6 +24,10 @@ from contextlib import contextmanager
import PIL
from nose.tools import assert_equals
from ming.orm.ormsession import ThreadLocalORMSession
+from tg import expose
+from pylons import tmpl_context as c, app_globals as g
+import mock
+from BeautifulSoup import BeautifulSoup
try:
import sfx
@@ -33,6 +37,8 @@ except ImportError:
from allura.tests import TestController
from allura.tests import decorators as td
from allura import model as M
+from allura.app import SitemapEntry
+from allura.lib.plugin import AdminExtension
@contextmanager
def audits(*messages):
@@ -726,3 +732,36 @@ class TestProjectAdmin(TestController):
assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[admin_id]
assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[mem_id]
assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[anon_id]
+
+
+ def test_admin_extension_sidebar(self):
+
+ class FooSettingsController(object):
+ @expose()
+ def index(self, *a, **kw):
+ return 'here the foo settings go'
+
+
+ class FooSettingsExtension(AdminExtension):
+ def update_project_sidebar_menu(self, sidebar_links):
+ base_url = c.project.url()+'admin/ext/'
+ sidebar_links.append(SitemapEntry('Foo Settings', base_url+'foo'))
+
+ @property
+ def project_admin_controllers(self):
+ return {
+ 'foo': FooSettingsController,
+ }
+
+ eps = {
+ 'admin': {
+ 'foo-settings': FooSettingsExtension,
+ }
+ }
+
+ with mock.patch.dict(g.entry_points, eps):
+ main_page = self.app.get('/admin/')
+ foo_page = main_page.click(description='Foo Settings')
+ url = foo_page.environ['PATH_INFO']
+ assert url.endswith('/admin/ext/foo'), url
+ assert_equals('here the foo settings go', foo_page.body)