Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
105 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations | ||
from zope.annotation import factory | ||
from zope import component | ||
from zope import interface | ||
from zope import schema | ||
|
||
from collective.rcse.settings import getDefaultSettings | ||
|
||
|
||
class ISettings(interface.Interface): | ||
settings = schema.Dict( | ||
title=u"Settings", | ||
key_type=schema.ASCIILine(), | ||
value_type=schema.ASCIILine() | ||
) | ||
|
||
|
||
class Settings(object): | ||
interface.implements(ISettings) | ||
component.adapts(IAttributeAnnotatable) | ||
|
||
def __init__(self): | ||
self.settings = getDefaultSettings() | ||
|
||
|
||
SettingsFactory = factory(Settings) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from Products.Five.browser import BrowserView | ||
|
||
from collective.rcse.content.settings import ISettings | ||
from collective.rcse.content.settings import getDefaultSettings | ||
|
||
|
||
class GetSettings(BrowserView): | ||
def __init__(self, context, request): | ||
self.context = context | ||
self.request = request | ||
self.settings = ISettings(self.context).settings | ||
self.default_settings = getDefaultSettings() | ||
|
||
def __call__(self): | ||
return self | ||
|
||
def get(self, key): | ||
if key in self.settings.keys(): | ||
return self.settings[key] | ||
if key in default_settings.keys(): | ||
return default_settings.keys() | ||
raise KeyError | ||
|
||
def set(self, key, value): | ||
self.settings[key] = value | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters