Cleanups. Containers created and BaseOption done better.
This commit is contained in:
parent
5bc9a42bb5
commit
d96cf3b809
9 changed files with 159 additions and 234 deletions
|
|
@ -198,6 +198,10 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
|
|||
def sessions(self):
|
||||
return AccountSessionHandler(self)
|
||||
|
||||
@lazy_property
|
||||
def options(self):
|
||||
return OptionHandler(self, options_dict=settings.OPTIONS_ACCOUNT_DEFAULT, save_category='option')
|
||||
|
||||
# Do not make this a lazy property; the web UI will not refresh it!
|
||||
@property
|
||||
def characters(self):
|
||||
|
|
@ -1384,10 +1388,6 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
|
|||
look_string = ("-" * 68) + "\n" + "".join(result) + "\n" + ("-" * 68)
|
||||
return look_string
|
||||
|
||||
@lazy_property
|
||||
def options(self):
|
||||
return OptionHandler(self, options_dict=settings.ACCOUNT_OPTIONS, save_category='option')
|
||||
|
||||
|
||||
class DefaultGuest(DefaultAccount):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
"""
|
||||
Styles (playing off CSS) are a way to change the colors and symbols used for standardized
|
||||
displays used in Evennia. Accounts all have a StyleHandler accessible via .style which
|
||||
retrieves per-Account settings, falling back to the global settings contained in settings.py.
|
||||
|
||||
"""
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class StyleHandler(object):
|
||||
category = 'style'
|
||||
|
||||
def __init__(self, acc):
|
||||
self.acc = acc
|
||||
|
||||
def set(self, option, value):
|
||||
pass
|
||||
|
||||
def get(self, option):
|
||||
"""
|
||||
Get the stored Style information from this Account's Attributes if possible.
|
||||
If not, fallback to the Global.
|
||||
|
||||
Args:
|
||||
option (str): The key of the Style to retrieve.
|
||||
|
||||
Returns:
|
||||
String or None
|
||||
"""
|
||||
stored = self.acc.attributes.get(option, category=self.category)
|
||||
if stored:
|
||||
return stored
|
||||
default = settings.DEFAULT_STYLES.get(option, None)
|
||||
if default:
|
||||
return default[2]
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue