Rename all instances of Player->Account.

This commit is contained in:
Griatch 2017-07-07 23:47:21 +02:00
parent a14e11640b
commit 5590ee2258
94 changed files with 1316 additions and 2327 deletions

View file

@ -19,7 +19,7 @@ Models covered:
Help
Message
Channel
Players
Accounts
"""
from django.conf import settings
from django.db import IntegrityError
@ -35,8 +35,8 @@ _Script = None
_ScriptDB = None
_HelpEntry = None
_Msg = None
_Player = None
_PlayerDB = None
_Account = None
_AccountDB = None
_to_object = None
_ChannelDB = None
_channelhandler = None
@ -44,7 +44,7 @@ _channelhandler = None
# limit symbol import from API
__all__ = ("create_object", "create_script", "create_help_entry",
"create_message", "create_channel", "create_player")
"create_message", "create_channel", "create_account")
_GA = object.__getattribute__
@ -129,7 +129,7 @@ object = create_object
#
# Script creation
def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
def create_script(typeclass=None, key=None, obj=None, account=None, locks=None,
interval=None, start_delay=None, repeats=None,
persistent=None, autostart=True, report_to=None, desc=None):
"""
@ -145,7 +145,7 @@ def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
#dbref will be set.
obj (Object): The entity on which this Script sits. If this
is `None`, we are creating a "global" script.
player (Player): The player on which this Script sits. It is
account (Account): The account on which this Script sits. It is
exclusiv to `obj`.
locks (str): one or more lockstrings, separated by semicolons.
interval (int): The triggering interval for this Script, in
@ -180,7 +180,7 @@ def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
# validate input
kwarg = {}
if key: kwarg["db_key"] = key
if player: kwarg["db_player"] = dbid_to_obj(player, _ScriptDB)
if account: kwarg["db_account"] = dbid_to_obj(account, _ScriptDB)
if obj: kwarg["db_obj"] = dbid_to_obj(obj, _ScriptDB)
if interval: kwarg["db_interval"] = interval
if start_delay: kwarg["db_start_delay"] = start_delay
@ -192,7 +192,7 @@ def create_script(typeclass=None, key=None, obj=None, player=None, locks=None,
new_script = typeclass(**kwarg)
# store the call signature for the signal
new_script._createdict = dict(key=key, obj=obj, player=player, locks=locks, interval=interval,
new_script._createdict = dict(key=key, obj=obj, account=account, locks=locks, interval=interval,
start_delay=start_delay, repeats=repeats, persistent=persistent,
autostart=autostart, report_to=report_to)
# this will trigger the save signal which in turn calls the
@ -263,15 +263,15 @@ def create_message(senderobj, message, channels=None, receivers=None, locks=None
database-persistent communication between entites.
Args:
senderobj (Object or Player): The entity sending the Msg.
senderobj (Object or Account): The entity sending the Msg.
message (str): Text with the message. Eventual headers, titles
etc should all be included in this text string. Formatting
will be retained.
channels (Channel, key or list): A channel or a list of channels to
send to. The channels may be actual channel objects or their
unique key strings.
receivers (Object, Player, str or list): A Player/Object to send
to, or a list of them. May be Player objects or playernames.
receivers (Object, Account, str or list): An Account/Object to send
to, or a list of them. May be Account objects or accountnames.
locks (str): Lock definition string.
header (str): Mime-type or other optional information for the message
@ -310,7 +310,7 @@ def create_channel(key, aliases=None, desc=None,
"""
Create A communication Channel. A Channel serves as a central hub
for distributing Msgs to groups of people without specifying the
receivers explicitly. Instead players may 'connect' to the channel
receivers explicitly. Instead accounts may 'connect' to the channel
and follow the flow of messages. By default the channel allows
access to all old messages, but this can be turned off with the
keep_log switch.
@ -352,28 +352,28 @@ channel = create_channel
#
# Player creation methods
# Account creation methods
#
def create_player(key, email, password,
def create_account(key, email, password,
typeclass=None,
is_superuser=False,
locks=None, permissions=None,
report_to=None):
"""
This creates a new player.
This creates a new account.
Args:
key (str): The player's name. This should be unique.
key (str): The account's name. This should be unique.
email (str): Email on valid addr@addr.domain form. This is
technically required but if set to `None`, an email of
`dummy@example.com` will be used as a placeholder.
password (str): Password in cleartext.
Kwargs:
is_superuser (bool): Wether or not this player is to be a superuser
is_superuser (bool): Wether or not this account is to be a superuser
locks (str): Lockstring.
permission (list): List of permission strings.
report_to (Object): An object with a msg() method to report
@ -389,42 +389,42 @@ def create_player(key, email, password,
operations and is thus not suitable for play-testing the game.
"""
global _PlayerDB
if not _PlayerDB:
from evennia.players.models import PlayerDB as _PlayerDB
global _AccountDB
if not _AccountDB:
from evennia.accounts.models import AccountDB as _AccountDB
typeclass = typeclass if typeclass else settings.BASE_PLAYER_TYPECLASS
typeclass = typeclass if typeclass else settings.BASE_ACCOUNT_TYPECLASS
if isinstance(typeclass, basestring):
# a path is given. Load the actual typeclass.
typeclass = class_from_module(typeclass, settings.TYPECLASS_PATHS)
# setup input for the create command. We use PlayerDB as baseclass
# setup input for the create command. We use AccountDB as baseclass
# here to give us maximum freedom (the typeclasses will load
# correctly when each object is recovered).
if not email:
email = "dummy@example.com"
if _PlayerDB.objects.filter(username__iexact=key):
raise ValueError("A Player with the name '%s' already exists." % key)
if _AccountDB.objects.filter(username__iexact=key):
raise ValueError("An Account with the name '%s' already exists." % key)
# this handles a given dbref-relocate to a player.
report_to = dbid_to_obj(report_to, _PlayerDB)
# this handles a given dbref-relocate to an account.
report_to = dbid_to_obj(report_to, _AccountDB)
# create the correct player entity, using the setup from
# create the correct account entity, using the setup from
# base django auth.
now = timezone.now()
email = typeclass.objects.normalize_email(email)
new_player = typeclass(username=key, email=email,
new_account = typeclass(username=key, email=email,
is_staff=is_superuser, is_superuser=is_superuser,
last_login=now, date_joined=now)
new_player.set_password(password)
new_player._createdict = dict(locks=locks, permissions=permissions, report_to=report_to)
new_account.set_password(password)
new_account._createdict = dict(locks=locks, permissions=permissions, report_to=report_to)
# saving will trigger the signal that calls the
# at_first_save hook on the typeclass, where the _createdict
# can be used.
new_player.save()
return new_player
new_account.save()
return new_account
# alias
player = create_player
account = create_account

View file

@ -373,7 +373,7 @@ def unpack_dbobj(item):
def pack_session(item):
"""
Handle the safe serializion of Sessions objects (these contain
hidden references to database objects (players, puppets) so they
hidden references to database objects (accounts, puppets) so they
can't be safely serialized).
Args:

View file

@ -242,13 +242,13 @@ class CmdEvMenuNode(Command):
caller = self.caller
# we store Session on the menu since this can be hard to
# get in multisession environemtns if caller is a Player.
# get in multisession environemtns if caller is an Account.
menu = caller.ndb._menutree
if not menu:
if _restore(caller):
return
orig_caller = caller
caller = caller.player if hasattr(caller, "player") else None
caller = caller.account if hasattr(caller, "account") else None
menu = caller.ndb._menutree if caller else None
if not menu:
if caller and _restore(caller):
@ -261,7 +261,7 @@ class CmdEvMenuNode(Command):
orig_caller.msg(err) # don't give the session as a kwarg here, direct to original
raise EvMenuError(err)
# we must do this after the caller with the menui has been correctly identified since it
# can be either Player, Object or Session (in the latter case this info will be superfluous).
# can be either Account, Object or Session (in the latter case this info will be superfluous).
caller.ndb._menutree._session = self.session
# we have a menu, use it.
menu.parse_input(self.raw_string)
@ -309,7 +309,7 @@ class EvMenu(object):
Initialize the menu tree and start the caller onto the first node.
Args:
caller (Object, Player or Session): The user of the menu.
caller (Object, Account or Session): The user of the menu.
menudata (str, module or dict): The full or relative path to the module
holding the menu tree data. All global functions in this module
whose name doesn't start with '_ ' will be parsed as menu nodes.
@ -361,7 +361,7 @@ class EvMenu(object):
startnode_input (str, optional): Send an input text to `startnode` as if
a user input text from a fictional previous node. When the server reloads,
the latest visited node will be re-run using this kwarg.
session (Session, optional): This is useful when calling EvMenu from a player
session (Session, optional): This is useful when calling EvMenu from an account
in multisession mode > 2. Note that this session only really relevant
for the very first display of the first node - after that, EvMenu itself
will keep the session updated from the command input. So a persistent
@ -777,7 +777,7 @@ class EvMenu(object):
Args:
optionlist (list): List of (key, description) tuples for every
option related to this node.
caller (Object, Player or None, optional): The caller of the node.
caller (Object, Account or None, optional): The caller of the node.
Returns:
options (str): The formatted option display.
@ -841,7 +841,7 @@ class EvMenu(object):
Args:
nodetext (str): The node text as returned by `self.nodetext_formatter`.
optionstext (str): The options display as returned by `self.options_formatter`.
caller (Object, Player or None, optional): The caller of the node.
caller (Object, Account or None, optional): The caller of the node.
Returns:
node (str): The formatted node to display.
@ -874,9 +874,9 @@ class CmdGetInput(Command):
caller = self.caller
try:
getinput = caller.ndb._getinput
if not getinput and hasattr(caller, "player"):
getinput = caller.player.ndb._getinput
caller = caller.player
if not getinput and hasattr(caller, "account"):
getinput = caller.account.ndb._getinput
caller = caller.account
callback = getinput._callback
caller.ndb._getinput._session = self.session
@ -925,7 +925,7 @@ def get_input(caller, prompt, callback, session=None, *args, **kwargs):
the caller.
Args:
caller (Player or Object): The entity being asked
caller (Account or Object): The entity being asked
the question. This should usually be an object
controlled by a user.
prompt (str): This text will be shown to the user,
@ -940,7 +940,7 @@ def get_input(caller, prompt, callback, session=None, *args, **kwargs):
accept input.
session (Session, optional): This allows to specify the
session to send the prompt to. It's usually only
needed if `caller` is a Player in multisession modes
needed if `caller` is an Account in multisession modes
greater than 2. The session is then updated by the
command and is available (for example in callbacks)
through `caller.ndb.getinput._session`.
@ -966,7 +966,7 @@ def get_input(caller, prompt, callback, session=None, *args, **kwargs):
`caller.ndb._getinput` is stored; this will be removed
when the prompt finishes.
If you need the specific Session of the caller (which
may not be easy to get if caller is a player in higher
may not be easy to get if caller is an account in higher
multisession modes), then it is available in the
callback through `caller.ndb._getinput._session`.

View file

@ -62,8 +62,8 @@ class CmdMore(Command):
Implement the command
"""
more = self.caller.ndb._more
if not more and hasattr(self.caller, "player"):
more = self.caller.player.ndb._more
if not more and hasattr(self.caller, "account"):
more = self.caller.account.ndb._more
if not more:
self.caller.msg("Error in loading the pager. Contact an admin.")
return
@ -94,8 +94,8 @@ class CmdMoreLook(Command):
Implement the command
"""
more = self.caller.ndb._more
if not more and hasattr(self.caller, "player"):
more = self.caller.player.ndb._more
if not more and hasattr(self.caller, "account"):
more = self.caller.account.ndb._more
if not more:
self.caller.msg("Error in loading the pager. Contact an admin.")
return
@ -124,7 +124,7 @@ class EvMore(object):
Initialization of the text handler.
Args:
caller (Object or Player): Entity reading the text.
caller (Object or Account): Entity reading the text.
text (str): The text to put under paging.
always_page (bool, optional): If `False`, the
pager will only kick in if `text` is too big
@ -268,7 +268,7 @@ def msg(caller, text="", always_page=False, session=None, justify_kwargs=None, *
More-supported version of msg, mimicking the normal msg method.
Args:
caller (Object or Player): Entity reading the text.
caller (Object or Account): Entity reading the text.
text (str): The text to put under paging.
always_page (bool, optional): If `False`, the
pager will only kick in if `text` is too big

View file

@ -16,11 +16,11 @@ the database model and call its 'objects' property.
Also remember that all commands in this file return lists (also if
there is only one match) unless noted otherwise.
Example: To reach the search method 'get_object_with_player'
Example: To reach the search method 'get_object_with_account'
in evennia/objects/managers.py:
> from evennia.objects.models import ObjectDB
> match = Object.objects.get_object_with_player(...)
> match = Object.objects.get_object_with_account(...)
"""
@ -30,15 +30,15 @@ Example: To reach the search method 'get_object_with_player'
from django.contrib.contenttypes.models import ContentType
# limit symbol import from API
__all__ = ("search_object", "search_player", "search_script",
__all__ = ("search_object", "search_account", "search_script",
"search_message", "search_channel", "search_help_entry",
"search_object_tag", "search_script_tag", "search_player_tag",
"search_object_tag", "search_script_tag", "search_account_tag",
"search_channel_tag")
# import objects this way to avoid circular import problems
ObjectDB = ContentType.objects.get(app_label="objects", model="objectdb").model_class()
PlayerDB = ContentType.objects.get(app_label="players", model="playerdb").model_class()
AccountDB = ContentType.objects.get(app_label="accounts", model="accountdb").model_class()
ScriptDB = ContentType.objects.get(app_label="scripts", model="scriptdb").model_class()
Msg = ContentType.objects.get(app_label="comms", model="msg").model_class()
Channel = ContentType.objects.get(app_label="comms", model="channeldb").model_class()
@ -99,20 +99,20 @@ object_search = search_object
objects = search_objects
#
# Search for players
# Search for accounts
#
# player_search(self, ostring)
# account_search(self, ostring)
# Searches for a particular player by name or
# Searches for a particular account by name or
# database id.
#
# ostring = a string or database id.
#
search_player = PlayerDB.objects.player_search
search_players = search_player
player_search = search_player
players = search_players
search_account = AccountDB.objects.account_search
search_accounts = search_account
account_search = search_account
accounts = search_accounts
#
# Searching for scripts
@ -140,8 +140,8 @@ scripts = search_scripts
# Search the message database for particular messages. At least one
# of the arguments must be given to do a search.
#
# sender - get messages sent by a particular player
# receiver - get messages received by a certain player
# sender - get messages sent by a particular account
# receiver - get messages received by a certain account
# channel - get messages sent to a particular channel
# freetext - Search for a text string in a message.
# NOTE: This can potentially be slow, so make sure to supply
@ -190,7 +190,7 @@ help_entries = search_help
# Locate Attributes
# search_object_attribute(key, category, value, strvalue) (also search_attribute works)
# search_player_attribute(key, category, value, strvalue) (also search_attribute works)
# search_account_attribute(key, category, value, strvalue) (also search_attribute works)
# search_script_attribute(key, category, value, strvalue) (also search_attribute works)
# search_channel_attribute(key, category, value, strvalue) (also search_attribute works)
@ -201,8 +201,8 @@ def search_object_attribute(key=None, category=None, value=None, strvalue=None):
return ObjectDB.objects.get_by_attribute(key=key, category=category, value=value, strvalue=strvalue)
def search_player_attribute(key=None, category=None, value=None, strvalue=None):
return PlayerDB.objects.get_by_attribute(key=key, category=category, value=value, strvalue=strvalue)
def search_account_attribute(key=None, category=None, value=None, strvalue=None):
return AccountDB.objects.get_by_attribute(key=key, category=category, value=value, strvalue=strvalue)
def search_script_attribute(key=None, category=None, value=None, strvalue=None):
@ -218,7 +218,7 @@ search_attribute_object = ObjectDB.objects.get_attribute
# Locate Tags
# search_object_tag(key=None, category=None) (also search_tag works)
# search_player_tag(key=None, category=None)
# search_account_tag(key=None, category=None)
# search_script_tag(key=None, category=None)
# search_channel_tag(key=None, category=None)
@ -246,9 +246,9 @@ def search_object_by_tag(key=None, category=None):
search_tag = search_object_by_tag # this is the most common case
def search_player_tag(key=None, category=None):
def search_account_tag(key=None, category=None):
"""
Find player based on tag or category.
Find account based on tag or category.
Args:
key (str, optional): The tag key to search for.
@ -257,12 +257,12 @@ def search_player_tag(key=None, category=None):
tags will be searched.
Returns:
matches (list): List of Players with tags matching
matches (list): List of Accounts with tags matching
the search criteria, or an empty list if no
matches were found.
"""
return PlayerDB.objects.get_by_tag(key=key, category=category)
return AccountDB.objects.get_by_tag(key=key, category=category)
def search_script_tag(key=None, category=None):

View file

@ -2,7 +2,7 @@ from django.conf import settings
from django.test import TestCase
from mock import Mock
from evennia.objects.objects import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit
from evennia.players.players import DefaultPlayer
from evennia.accounts.accounts import DefaultAccount
from evennia.scripts.scripts import DefaultScript
from evennia.server.serversession import ServerSession
from evennia.server.sessionhandler import SESSIONS
@ -18,7 +18,7 @@ class EvenniaTest(TestCase):
"""
Base test for Evennia, sets up a basic environment.
"""
player_typeclass = DefaultPlayer
account_typeclass = DefaultAccount
object_typeclass = DefaultObject
character_typeclass = DefaultCharacter
exit_typeclass = DefaultExit
@ -29,8 +29,8 @@ class EvenniaTest(TestCase):
"""
Sets up testing environment
"""
self.player = create.create_player("TestPlayer", email="test@test.com", password="testpassword", typeclass=self.player_typeclass)
self.player2 = create.create_player("TestPlayer2", email="test@test.com", password="testpassword", typeclass=self.player_typeclass)
self.account = create.create_account("TestAccount", email="test@test.com", password="testpassword", typeclass=self.account_typeclass)
self.account2 = create.create_account("TestAccount2", email="test@test.com", password="testpassword", typeclass=self.account_typeclass)
self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True)
self.room1.db.desc = "room_desc"
settings.DEFAULT_HOME = "#%i" % self.room1.id # we must have a default home
@ -41,12 +41,12 @@ class EvenniaTest(TestCase):
self.char1 = create.create_object(self.character_typeclass, key="Char", location=self.room1, home=self.room1)
self.char1.permissions.add("Developer")
self.char2 = create.create_object(self.character_typeclass, key="Char2", location=self.room1, home=self.room1)
self.char1.player = self.player
self.player.db._last_puppet = self.char1
self.char2.player = self.player2
self.player2.db._last_puppet = self.char2
self.char1.account = self.account
self.account.db._last_puppet = self.char1
self.char2.account = self.account2
self.account2.db._last_puppet = self.char2
self.script = create.create_script(self.script_typeclass, key="Script")
self.player.permissions.add("Developer")
self.account.permissions.add("Developer")
# set up a fake session
@ -55,12 +55,12 @@ class EvenniaTest(TestCase):
dummysession.sessid = 1
SESSIONS.portal_connect(dummysession.get_sync_data()) # note that this creates a new Session!
session = SESSIONS.session_from_sessid(1) # the real session
SESSIONS.login(session, self.player, testmode=True)
SESSIONS.login(session, self.account, testmode=True)
self.session = session
def tearDown(self):
flush_cache()
del SESSIONS[self.session.sessid]
self.player.delete()
self.player2.delete()
self.account.delete()
self.account2.delete()
super(EvenniaTest, self).tearDown()

View file

@ -386,7 +386,7 @@ class TestEvForm(TestCase):
u'| |\n'
u'| Name: \x1b[0m\x1b[1m\x1b[32mTom\x1b[1m\x1b[32m \x1b'
u'[1m\x1b[32mthe\x1b[1m\x1b[32m \x1b[0m \x1b[0m '
u'Player: \x1b[0m\x1b[1m\x1b[33mGriatch '
u'Account: \x1b[0m\x1b[1m\x1b[33mGriatch '
u'\x1b[0m\x1b[0m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[0m\x1b[0m '
u'|\n'
u'| \x1b[0m\x1b[1m\x1b[32mBouncer\x1b[0m \x1b[0m |\n'

View file

@ -1384,12 +1384,12 @@ def class_from_module(path, defaultpaths=None):
object_from_module = class_from_module
def init_new_player(player):
def init_new_account(account):
"""
Deprecated.
"""
from evennia.utils import logger
logger.log_dep("evennia.utils.utils.init_new_player is DEPRECATED and should not be used.")
logger.log_dep("evennia.utils.utils.init_new_account is DEPRECATED and should not be used.")
def string_similarity(string1, string2):