You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/04/16 19:05:02 UTC
[05/17] allura git commit: [#7864] remove Property with nested
get/setters, since sys.settrace causes pydev/PyCharm debugger not to work
[#7864] remove Property with nested get/setters, since sys.settrace causes pydev/PyCharm debugger not to work
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/c72837df
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c72837df
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c72837df
Branch: refs/heads/hs/7852
Commit: c72837df2062465c9f75bcde6bb747df38acf243
Parents: fa548be
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Apr 7 15:37:53 2015 -0400
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Apr 15 11:04:03 2015 +0000
----------------------------------------------------------------------
Allura/allura/lib/decorators.py | 18 ---------
ForgeBlog/forgeblog/main.py | 40 +++++++++---------
ForgeWiki/forgewiki/wiki_main.py | 76 +++++++++++++++++------------------
3 files changed, 58 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/c72837df/Allura/allura/lib/decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/decorators.py b/Allura/allura/lib/decorators.py
index d472758..cb5cfc5 100644
--- a/Allura/allura/lib/decorators.py
+++ b/Allura/allura/lib/decorators.py
@@ -188,24 +188,6 @@ class log_action(object): # pragma no cover
return extra
-def Property(function):
- '''Decorator to easily assign descriptors based on sub-function names
- See <http://code.activestate.com/recipes/410698-property-decorator-for-python-24/>
- '''
- keys = 'fget', 'fset', 'fdel'
- func_locals = {'doc': function.__doc__}
-
- def probeFunc(frame, event, arg):
- if event == 'return':
- locals = frame.f_locals
- func_locals.update(dict((k, locals.get(k)) for k in keys))
- sys.settrace(None)
- return probeFunc
- sys.settrace(probeFunc)
- function()
- return property(**func_locals)
-
-
def getattr_(obj, name, default_thunk):
"Similar to .setdefault in dictionaries."
try:
http://git-wip-us.apache.org/repos/asf/allura/blob/c72837df/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 93cd01b..160b94e 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -39,7 +39,7 @@ from allura.app import Application, SitemapEntry
from allura.app import DefaultAdminController
from allura.lib import helpers as h
from allura.lib.search import search_app
-from allura.lib.decorators import require_post, Property
+from allura.lib.decorators import require_post
from allura.lib.security import has_access, require_access
from allura.lib import widgets as w
from allura.lib.widgets.subscriptions import SubscribeForm
@@ -106,25 +106,25 @@ class ForgeBlogApp(Application):
self.admin = BlogAdminController(self)
self.api_root = RootRestController()
- @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()
+ @property
+ def external_feeds_list(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
+
+ @external_feeds_list.setter
+ def external_feeds_list(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, '.')]
http://git-wip-us.apache.org/repos/asf/allura/blob/c72837df/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index ecbddef..a5b3d3e 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -35,7 +35,7 @@ from allura import model as M
from allura.lib import helpers as h
from allura.app import Application, SitemapEntry, DefaultAdminController
from allura.lib.search import search_app
-from allura.lib.decorators import require_post, Property
+from allura.lib.decorators import require_post
from allura.lib.security import require_access, has_access
from allura.controllers import AppDiscussionController, BaseController, AppDiscussionRestController
from allura.controllers import DispatchIndex
@@ -129,25 +129,25 @@ class ForgeWikiApp(Application):
log.exception('Error getting artifact %s', topic)
self.handle_artifact_message(page, message)
- @Property
- def root_page_name():
- def fget(self):
- globals = WM.Globals.query.get(app_config_id=self.config._id)
- if globals is not None:
- page_name = globals.root
- else:
- page_name = self.default_root_page_name
- return page_name
-
- def fset(self, new_root_page_name):
- globals = WM.Globals.query.get(app_config_id=self.config._id)
- if globals is not None:
- globals.root = new_root_page_name
- elif new_root_page_name != self.default_root_page_name:
- globals = WM.Globals(
- app_config_id=self.config._id, root=new_root_page_name)
- if globals is not None:
- session(globals).flush(globals)
+ @property
+ def root_page_name(self):
+ globals = WM.Globals.query.get(app_config_id=self.config._id)
+ if globals is not None:
+ page_name = globals.root
+ else:
+ page_name = self.default_root_page_name
+ return page_name
+
+ @root_page_name.setter
+ def root_page_name(self, new_root_page_name):
+ globals = WM.Globals.query.get(app_config_id=self.config._id)
+ if globals is not None:
+ globals.root = new_root_page_name
+ elif new_root_page_name != self.default_root_page_name:
+ globals = WM.Globals(
+ app_config_id=self.config._id, root=new_root_page_name)
+ if globals is not None:
+ session(globals).flush(globals)
def default_root_page_text(self):
return """Welcome to your wiki!
@@ -159,29 +159,29 @@ The wiki uses [Markdown](%s) syntax.
[[members limit=20]]
""" % (self.url + 'markdown_syntax/')
- @Property
- def show_discussion():
- def fget(self):
- return self.config.options.get('show_discussion', True)
+ @property
+ def show_discussion(self):
+ return self.config.options.get('show_discussion', True)
- def fset(self, show):
- self.config.options['show_discussion'] = bool(show)
+ @show_discussion.setter
+ def show_discussion(self, show):
+ self.config.options['show_discussion'] = bool(show)
- @Property
- def show_left_bar():
- def fget(self):
- return self.config.options.get('show_left_bar', True)
+ @property
+ def show_left_bar(self):
+ return self.config.options.get('show_left_bar', True)
- def fset(self, show):
- self.config.options['show_left_bar'] = bool(show)
+ @show_left_bar.setter
+ def show_left_bar(self, show):
+ self.config.options['show_left_bar'] = bool(show)
- @Property
- def show_right_bar():
- def fget(self):
- return self.config.options.get('show_right_bar', True)
+ @property
+ def show_right_bar(self):
+ return self.config.options.get('show_right_bar', True)
- def fset(self, show):
- self.config.options['show_right_bar'] = bool(show)
+ @show_right_bar.setter
+ def show_right_bar(self, show):
+ self.config.options['show_right_bar'] = bool(show)
def main_menu(self):
'''Apps should provide their entries to be added to the main nav