OBS: Run migrate! Made exit's destination into a database field for performance. Fixed a too greedy @reload that caused ContentTypes to loose information. Resolves issue 157.
Migrate with: "python manage.py migrate"
This commit is contained in:
parent
0cff54f136
commit
6c53ec2bdb
11 changed files with 227 additions and 84 deletions
|
|
@ -575,7 +575,7 @@ class CmdDig(ObjManipCommand):
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
|
|
||||||
if not self.lhs:
|
if not self.lhs:
|
||||||
string = "Usage: @dig[/teleport] roomname[;alias;alias...][:parent] [= exit_there"
|
string = "Usage:@ dig[/teleport] roomname[;alias;alias...][:parent] [= exit_there"
|
||||||
string += "[;alias;alias..][:parent]] "
|
string += "[;alias;alias..][:parent]] "
|
||||||
string += "[, exit_back_here[;alias;alias..][:parent]]"
|
string += "[, exit_back_here[;alias;alias..][:parent]]"
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
|
|
@ -601,8 +601,12 @@ class CmdDig(ObjManipCommand):
|
||||||
typeclass = "%s.%s" % (settings.BASE_TYPECLASS_PATH,
|
typeclass = "%s.%s" % (settings.BASE_TYPECLASS_PATH,
|
||||||
typeclass)
|
typeclass)
|
||||||
|
|
||||||
|
lockstring = "control:id(%s) or perm(Immortal); delete:id(%s) or perm(Wizard); edit:id(%s) or perm(Wizard)"
|
||||||
|
lockstring = lockstring % (caller.dbref, caller.dbref, caller.dbref)
|
||||||
|
|
||||||
new_room = create.create_object(typeclass, room["name"],
|
new_room = create.create_object(typeclass, room["name"],
|
||||||
aliases=room["aliases"])
|
aliases=room["aliases"])
|
||||||
|
new_room.locks.add(lockstring)
|
||||||
room_string = "Created room '%s' of type %s." % (new_room.name, typeclass)
|
room_string = "Created room '%s' of type %s." % (new_room.name, typeclass)
|
||||||
|
|
||||||
exit_to_string = ""
|
exit_to_string = ""
|
||||||
|
|
@ -631,7 +635,8 @@ class CmdDig(ObjManipCommand):
|
||||||
new_to_exit = create.create_object(typeclass, to_exit["name"],
|
new_to_exit = create.create_object(typeclass, to_exit["name"],
|
||||||
location,
|
location,
|
||||||
aliases=to_exit["aliases"])
|
aliases=to_exit["aliases"])
|
||||||
new_to_exit.db._destination = new_room
|
new_to_exit.destination = new_room
|
||||||
|
new_to_exit.locks.add(lockstring)
|
||||||
exit_to_string = "\nCreated new Exit to new room: %s (aliases: %s)."
|
exit_to_string = "\nCreated new Exit to new room: %s (aliases: %s)."
|
||||||
exit_to_string = exit_to_string % (new_to_exit.name,
|
exit_to_string = exit_to_string % (new_to_exit.name,
|
||||||
new_to_exit.aliases)
|
new_to_exit.aliases)
|
||||||
|
|
@ -659,7 +664,8 @@ class CmdDig(ObjManipCommand):
|
||||||
new_back_exit = create.create_object(typeclass, back_exit["name"],
|
new_back_exit = create.create_object(typeclass, back_exit["name"],
|
||||||
new_room,
|
new_room,
|
||||||
aliases=back_exit["aliases"])
|
aliases=back_exit["aliases"])
|
||||||
new_back_exit.db._destination = location
|
new_back_exit.destination = location
|
||||||
|
new_back_exit.locks.add(lockstring)
|
||||||
exit_back_string = "\nExit back from new room: %s (aliases: %s)."
|
exit_back_string = "\nExit back from new room: %s (aliases: %s)."
|
||||||
exit_back_string = exit_back_string % (new_back_exit.name,
|
exit_back_string = exit_back_string % (new_back_exit.name,
|
||||||
new_back_exit.aliases)
|
new_back_exit.aliases)
|
||||||
|
|
@ -714,13 +720,13 @@ class CmdLink(MuxCommand):
|
||||||
target = caller.search(self.rhs, global_search=True)
|
target = caller.search(self.rhs, global_search=True)
|
||||||
if not target:
|
if not target:
|
||||||
return
|
return
|
||||||
# if obj is an exit (has db attribute _destination),
|
# if obj is an exit (has property destination),
|
||||||
# set that, otherwise set home.
|
# set that, otherwise set home.
|
||||||
if obj.db._destination:
|
if obj.destination:
|
||||||
obj.db._destination = target
|
obj.destination = target
|
||||||
if "twoway" in self.switches:
|
if "twoway" in self.switches:
|
||||||
if target.db._destination:
|
if target.destination:
|
||||||
target.db._destination = obj
|
target.destination = obj
|
||||||
string = "Link created %s <-> %s (two-way)." % (obj.name, target.name)
|
string = "Link created %s <-> %s (two-way)." % (obj.name, target.name)
|
||||||
else:
|
else:
|
||||||
string = "Cannot create two-way link to non-exit."
|
string = "Cannot create two-way link to non-exit."
|
||||||
|
|
@ -728,7 +734,7 @@ class CmdLink(MuxCommand):
|
||||||
else:
|
else:
|
||||||
string = "Link created %s -> %s (one way)." % (obj.name, target.name)
|
string = "Link created %s -> %s (one way)." % (obj.name, target.name)
|
||||||
else:
|
else:
|
||||||
# obj is not an exit (has not attribute _destination),
|
# obj is not an exit (has not property destination),
|
||||||
# so set home instead
|
# so set home instead
|
||||||
obj.home = target
|
obj.home = target
|
||||||
string = "Set %s's home to %s." % (obj.name, target.name)
|
string = "Set %s's home to %s." % (obj.name, target.name)
|
||||||
|
|
@ -737,20 +743,19 @@ class CmdLink(MuxCommand):
|
||||||
# this means that no = was given (otherwise rhs
|
# this means that no = was given (otherwise rhs
|
||||||
# would have been an empty string). So we inspect
|
# would have been an empty string). So we inspect
|
||||||
# the home/destination on object
|
# the home/destination on object
|
||||||
dest = obj.db._destination
|
dest = obj.destination
|
||||||
if dest:
|
if dest:
|
||||||
"%s is an exit to %s." % (obj.name, dest.name)
|
"%s is an exit to %s." % (obj.name, dest.name)
|
||||||
else:
|
else:
|
||||||
string = "%s has home %s." % (obj.name, obj.home)
|
string = "%s has home %s." % (obj.name, obj.home)
|
||||||
else:
|
else:
|
||||||
# We gave the command @link 'obj = ' which means we want to
|
# We gave the command @link 'obj = ' which means we want to
|
||||||
# clear _destination or set home to None.
|
# clear destination or set home to None.
|
||||||
if obj.db._destination:
|
if obj.destination:
|
||||||
obj.db._destination = "None" # it can't be None, or _destination would
|
del obj.destination
|
||||||
# be deleted and obj cease being an exit!
|
|
||||||
string = "Exit %s no longer links anywhere." % obj.name
|
string = "Exit %s no longer links anywhere." % obj.name
|
||||||
else:
|
else:
|
||||||
obj.home = None
|
del obj.home
|
||||||
string = "%s no longer has a home." % obj.name
|
string = "%s no longer has a home." % obj.name
|
||||||
# give feedback
|
# give feedback
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
|
|
@ -977,19 +982,19 @@ class CmdOpen(ObjManipCommand):
|
||||||
return
|
return
|
||||||
if exit_obj:
|
if exit_obj:
|
||||||
exit_obj = exit_obj[0]
|
exit_obj = exit_obj[0]
|
||||||
if not exit_obj.db._destination:
|
if not exit_obj.destination:
|
||||||
# we are trying to link a non-exit
|
# we are trying to link a non-exit
|
||||||
string = "'%s' already exists and is not an exit!\nIf you want to convert it "
|
string = "'%s' already exists and is not an exit!\nIf you want to convert it "
|
||||||
string += "to an exit, you must assign it an attribute '_destination' first."
|
string += "to an exit, you must assign an object to the 'destination' property first."
|
||||||
caller.msg(string % exit_name)
|
caller.msg(string % exit_name)
|
||||||
return None
|
return None
|
||||||
# we are re-linking an old exit.
|
# we are re-linking an old exit.
|
||||||
old_destination = exit_obj.db._destination
|
old_destination = exit_obj.destination
|
||||||
if old_destination:
|
if old_destination:
|
||||||
string = "Exit %s already exists." % exit_name
|
string = "Exit %s already exists." % exit_name
|
||||||
if old_destination.id != destination.id:
|
if old_destination.id != destination.id:
|
||||||
# reroute the old exit.
|
# reroute the old exit.
|
||||||
exit_obj.db._destination = destination
|
exit_obj.destination = destination
|
||||||
exit_obj.aliases = exit_aliases
|
exit_obj.aliases = exit_aliases
|
||||||
string += " Rerouted its old destination '%s' to '%s' and changed aliases." % \
|
string += " Rerouted its old destination '%s' to '%s' and changed aliases." % \
|
||||||
(old_destination.name, destination.name)
|
(old_destination.name, destination.name)
|
||||||
|
|
@ -1002,8 +1007,8 @@ class CmdOpen(ObjManipCommand):
|
||||||
location=location,
|
location=location,
|
||||||
aliases=exit_aliases)
|
aliases=exit_aliases)
|
||||||
if exit_obj:
|
if exit_obj:
|
||||||
# storing an attribute _destination is what makes it an exit!
|
# storing a destination is what makes it an exit!
|
||||||
exit_obj.db._destination = destination
|
exit_obj.destination = destination
|
||||||
string = "Created new Exit '%s' to %s (aliases: %s)." % (exit_name,
|
string = "Created new Exit '%s' to %s (aliases: %s)." % (exit_name,
|
||||||
destination.name,
|
destination.name,
|
||||||
exit_aliases)
|
exit_aliases)
|
||||||
|
|
@ -1453,6 +1458,8 @@ class CmdExamine(ObjManipCommand):
|
||||||
|
|
||||||
string += "\n{wTypeclass{n: %s (%s)" % (obj.typeclass, obj.typeclass_path)
|
string += "\n{wTypeclass{n: %s (%s)" % (obj.typeclass, obj.typeclass_path)
|
||||||
string += "\n{wLocation{n: %s" % obj.location
|
string += "\n{wLocation{n: %s" % obj.location
|
||||||
|
if obj.destination:
|
||||||
|
string += "\n{wDestination{n: %s" % obj.destination
|
||||||
perms = obj.permissions
|
perms = obj.permissions
|
||||||
if perms:
|
if perms:
|
||||||
string += "\n{wPermissions{n: %s" % (", ".join(perms))
|
string += "\n{wPermissions{n: %s" % (", ".join(perms))
|
||||||
|
|
@ -1470,7 +1477,7 @@ class CmdExamine(ObjManipCommand):
|
||||||
pobjs = []
|
pobjs = []
|
||||||
things = []
|
things = []
|
||||||
for content in obj.contents:
|
for content in obj.contents:
|
||||||
if content.db._destination:
|
if content.destination:
|
||||||
# an exit
|
# an exit
|
||||||
exits.append(content)
|
exits.append(content)
|
||||||
elif content.player:
|
elif content.player:
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ class CmdGet(MuxCommand):
|
||||||
if caller == obj:
|
if caller == obj:
|
||||||
caller.msg("You can't get yourself.")
|
caller.msg("You can't get yourself.")
|
||||||
return
|
return
|
||||||
if obj.player or obj.db._destination:
|
if obj.player or obj.destination:
|
||||||
# don't allow picking up player objects, nor exits.
|
# don't allow picking up player objects, nor exits.
|
||||||
caller.msg("You can't get that.")
|
caller.msg("You can't get that.")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ class SystemUseExit(MuxCommand):
|
||||||
exi = caller.search(exit_name)
|
exi = caller.search(exit_name)
|
||||||
if not exi:
|
if not exi:
|
||||||
return
|
return
|
||||||
destination = exi.attr('_destination')
|
destination = exi.destination
|
||||||
if not destination:
|
if not destination:
|
||||||
return
|
return
|
||||||
if exit.access(caller, 'traverse'):
|
if exit.access(caller, 'traverse'):
|
||||||
|
|
|
||||||
|
|
@ -37,32 +37,8 @@ class CmdReload(MuxCommand):
|
||||||
"""
|
"""
|
||||||
Reload the system.
|
Reload the system.
|
||||||
"""
|
"""
|
||||||
caller = self.caller
|
|
||||||
reloads.start_reload_loop()
|
reloads.start_reload_loop()
|
||||||
|
|
||||||
#reloads.reload_modules()
|
|
||||||
# max_attempts = 4
|
|
||||||
# for attempt in range(max_attempts):
|
|
||||||
# # if reload modules take a long time,
|
|
||||||
# # we might end up in a situation where
|
|
||||||
# # the subsequent commands fail since they
|
|
||||||
# # can't find the reloads module (due to it
|
|
||||||
# # not yet fully loaded). So we retry a few
|
|
||||||
# # times before giving up.
|
|
||||||
# try:
|
|
||||||
# reloads.reload_scripts()
|
|
||||||
# reloads.reload_commands()
|
|
||||||
# break
|
|
||||||
# except AttributeError:
|
|
||||||
# if attempt < max_attempts-1:
|
|
||||||
# caller.msg(" Waiting for modules(s) to finish (%s) ..." % attempt)
|
|
||||||
# else:
|
|
||||||
# string = "{r ... The module(s) took too long to reload, "
|
|
||||||
# string += "\n so the remaining reloads where skipped."
|
|
||||||
# string += "\n Re-run @reload again when modules have fully "
|
|
||||||
# string += "\n re-initialized.{n"
|
|
||||||
# caller.msg(string)
|
|
||||||
|
|
||||||
class CmdPy(MuxCommand):
|
class CmdPy(MuxCommand):
|
||||||
"""
|
"""
|
||||||
Execute a snippet of python code
|
Execute a snippet of python code
|
||||||
|
|
@ -296,14 +272,14 @@ class CmdObjects(MuxCommand):
|
||||||
nobjs = ObjectDB.objects.count()
|
nobjs = ObjectDB.objects.count()
|
||||||
base_typeclass = settings.BASE_CHARACTER_TYPECLASS
|
base_typeclass = settings.BASE_CHARACTER_TYPECLASS
|
||||||
nchars = ObjectDB.objects.filter(db_typeclass_path=base_typeclass).count()
|
nchars = ObjectDB.objects.filter(db_typeclass_path=base_typeclass).count()
|
||||||
nrooms = ObjectDB.objects.filter(db_location=None).exclude(db_typeclass_path=base_typeclass).count()
|
nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=base_typeclass).count()
|
||||||
nexits = sum([1 for obj in ObjectDB.objects.filter(db_location=None) if obj.get_attribute('_destination')])
|
nexits = ObjectDB.objects.filter(db_location__isnull=False, db_destination__isnull=False).count()
|
||||||
|
|
||||||
string += "\n{wPlayers:{n %i" % nplayers
|
string += "\n{wPlayers:{n %i" % nplayers
|
||||||
string += "\n{wObjects:{n %i" % nobjs
|
string += "\n{wObjects:{n %i" % nobjs
|
||||||
string += "\n{w Characters (base type):{n %i" % nchars
|
string += "\n{w Characters (base type):{n %i" % nchars
|
||||||
string += "\n{w Rooms (location==None):{n %i" % nrooms
|
string += "\n{w Rooms (location==None):{n %i" % nrooms
|
||||||
string += "\n{w Exits (.db._destination!=None):{n %i" % nexits
|
string += "\n{w Exits (destination!=None):{n %i" % nexits
|
||||||
string += "\n{w Other:{n %i\n" % (nobjs - nchars - nrooms - nexits)
|
string += "\n{w Other:{n %i\n" % (nobjs - nchars - nrooms - nexits)
|
||||||
|
|
||||||
dbtotals = ObjectDB.objects.object_totals()
|
dbtotals = ObjectDB.objects.object_totals()
|
||||||
|
|
@ -320,7 +296,7 @@ class CmdObjects(MuxCommand):
|
||||||
string += srow
|
string += srow
|
||||||
|
|
||||||
string += "\n\n{wLast %s Objects created:{n" % nlim
|
string += "\n\n{wLast %s Objects created:{n" % nlim
|
||||||
objs = list(ObjectDB.objects.all())[-nlim:]
|
objs = ObjectDB.objects.all()[max(0, nobjs-nlim):]
|
||||||
|
|
||||||
table = [["Created"], ["dbref"], ["name"], ["typeclass"]]
|
table = [["Created"], ["dbref"], ["name"], ["typeclass"]]
|
||||||
for i, obj in enumerate(objs):
|
for i, obj in enumerate(objs):
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ class ExitHandler(object):
|
||||||
|
|
||||||
# use exits to create searchable "commands" for the cmdhandler
|
# use exits to create searchable "commands" for the cmdhandler
|
||||||
for exi in (exi for exi in location.contents
|
for exi in (exi for exi in location.contents
|
||||||
if exi.has_attribute('_destination')):
|
if exi.destination):
|
||||||
if exi.id in self.cached_exit_cmds:
|
if exi.id in self.cached_exit_cmds:
|
||||||
# retrieve from cache
|
# retrieve from cache
|
||||||
exit_cmdset.add(self.cached_exit_cmds[exi.id])
|
exit_cmdset.add(self.cached_exit_cmds[exi.id])
|
||||||
|
|
@ -81,7 +81,7 @@ class ExitHandler(object):
|
||||||
cmd.obj = exi
|
cmd.obj = exi
|
||||||
if exi.aliases:
|
if exi.aliases:
|
||||||
cmd.aliases = exi.aliases
|
cmd.aliases = exi.aliases
|
||||||
cmd.destination = exi.attr('_destination')
|
cmd.destination = exi.destination
|
||||||
exit_cmdset.add(cmd)
|
exit_cmdset.add(cmd)
|
||||||
self.cached_exit_cmds[exi.id] = cmd
|
self.cached_exit_cmds[exi.id] = cmd
|
||||||
return exit_cmdset
|
return exit_cmdset
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
import datetime
|
||||||
|
from south.db import db
|
||||||
|
from south.v2 import SchemaMigration
|
||||||
|
from django.db import models
|
||||||
|
from src.objects.models import ObjectDB
|
||||||
|
|
||||||
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
|
def forwards(self, orm):
|
||||||
|
|
||||||
|
# Adding field 'ObjectDB.db_destination'
|
||||||
|
db.add_column('objects_objectdb', 'db_destination', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='destinations_set', null=True, to=orm['objects.ObjectDB']), keep_default=False)
|
||||||
|
|
||||||
|
# move all exits to the new property
|
||||||
|
for exi in ObjectDB.objects.get_objs_with_attr('_destination'):
|
||||||
|
exi.destination = exi.db._destination
|
||||||
|
exi.del_attribute('_destination')
|
||||||
|
|
||||||
|
def backwards(self, orm):
|
||||||
|
|
||||||
|
# Deleting field 'ObjectDB.db_destination'
|
||||||
|
db.delete_column('objects_objectdb', 'db_destination_id')
|
||||||
|
|
||||||
|
|
||||||
|
models = {
|
||||||
|
'auth.group': {
|
||||||
|
'Meta': {'object_name': 'Group'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||||
|
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'auth.permission': {
|
||||||
|
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||||
|
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||||
|
},
|
||||||
|
'auth.user': {
|
||||||
|
'Meta': {'object_name': 'User'},
|
||||||
|
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||||
|
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||||
|
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||||
|
},
|
||||||
|
'contenttypes.contenttype': {
|
||||||
|
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||||
|
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||||
|
},
|
||||||
|
'objects.alias': {
|
||||||
|
'Meta': {'object_name': 'Alias'},
|
||||||
|
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
|
||||||
|
},
|
||||||
|
'objects.nick': {
|
||||||
|
'Meta': {'unique_together': "(('db_nick', 'db_type', 'db_obj'),)", 'object_name': 'Nick'},
|
||||||
|
'db_nick': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
|
||||||
|
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']"}),
|
||||||
|
'db_real': ('django.db.models.fields.TextField', [], {}),
|
||||||
|
'db_type': ('django.db.models.fields.CharField', [], {'default': "'inputline'", 'max_length': '16', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
|
||||||
|
},
|
||||||
|
'objects.objattribute': {
|
||||||
|
'Meta': {'object_name': 'ObjAttribute'},
|
||||||
|
'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']"}),
|
||||||
|
'db_value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
|
||||||
|
},
|
||||||
|
'objects.objectdb': {
|
||||||
|
'Meta': {'object_name': 'ObjectDB'},
|
||||||
|
'db_cmdset_storage': ('django.db.models.fields.TextField', [], {'null': 'True'}),
|
||||||
|
'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'db_destination': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'destinations_set'", 'null': 'True', 'to': "orm['objects.ObjectDB']"}),
|
||||||
|
'db_home': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'homes_set'", 'null': 'True', 'to': "orm['objects.ObjectDB']"}),
|
||||||
|
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'db_location': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locations_set'", 'null': 'True', 'to': "orm['objects.ObjectDB']"}),
|
||||||
|
'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
|
||||||
|
'db_player': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['players.PlayerDB']", 'null': 'True', 'blank': 'True'}),
|
||||||
|
'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
|
||||||
|
},
|
||||||
|
'players.playerdb': {
|
||||||
|
'Meta': {'object_name': 'PlayerDB'},
|
||||||
|
'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['objects.ObjectDB']", 'null': 'True'}),
|
||||||
|
'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
|
||||||
|
'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
complete_apps = ['objects']
|
||||||
|
|
@ -217,6 +217,9 @@ class ObjectDB(TypedObject):
|
||||||
# a safety location, this usually don't change much.
|
# a safety location, this usually don't change much.
|
||||||
db_home = models.ForeignKey('self', related_name="homes_set",
|
db_home = models.ForeignKey('self', related_name="homes_set",
|
||||||
blank=True, null=True)
|
blank=True, null=True)
|
||||||
|
# destination of this object - primarily used by exits.
|
||||||
|
db_destination = models.ForeignKey('self', related_name="destinations_set",
|
||||||
|
blank=True, null=True)
|
||||||
# database storage of persistant cmdsets.
|
# database storage of persistant cmdsets.
|
||||||
db_cmdset_storage = models.TextField(null=True)
|
db_cmdset_storage = models.TextField(null=True)
|
||||||
|
|
||||||
|
|
@ -325,6 +328,7 @@ class ObjectDB(TypedObject):
|
||||||
def location_del(self):
|
def location_del(self):
|
||||||
"Deleter. Allows for del self.location"
|
"Deleter. Allows for del self.location"
|
||||||
self.db_location = None
|
self.db_location = None
|
||||||
|
self.save()
|
||||||
location = property(location_get, location_set, location_del)
|
location = property(location_get, location_set, location_del)
|
||||||
|
|
||||||
# home property (wraps db_home)
|
# home property (wraps db_home)
|
||||||
|
|
@ -362,8 +366,48 @@ class ObjectDB(TypedObject):
|
||||||
def home_del(self):
|
def home_del(self):
|
||||||
"Deleter. Allows for del self.home."
|
"Deleter. Allows for del self.home."
|
||||||
self.db_home = None
|
self.db_home = None
|
||||||
|
self.save()
|
||||||
home = property(home_get, home_set, home_del)
|
home = property(home_get, home_set, home_del)
|
||||||
|
|
||||||
|
# destination property (wraps db_destination)
|
||||||
|
#@property
|
||||||
|
def destination_get(self):
|
||||||
|
"Getter. Allows for value = self.destination."
|
||||||
|
dest = self.db_destination
|
||||||
|
if dest:
|
||||||
|
return dest.typeclass(dest)
|
||||||
|
return None
|
||||||
|
#@destination.setter
|
||||||
|
def destination_set(self, destination):
|
||||||
|
"Setter. Allows for self.destination = destination"
|
||||||
|
try:
|
||||||
|
if destination == None or type(destination) == ObjectDB:
|
||||||
|
# destination is None or a valid object
|
||||||
|
dest = destination
|
||||||
|
elif ObjectDB.objects.dbref(destination):
|
||||||
|
# destination is a dbref; search
|
||||||
|
dest = ObjectDB.objects.dbref_search(destination)
|
||||||
|
if dest and hasattr(dest,'dbobj'):
|
||||||
|
dest = dest.dbobj
|
||||||
|
else:
|
||||||
|
dest = destination.dbobj
|
||||||
|
else:
|
||||||
|
dest = destination.dbobj
|
||||||
|
self.db_destination = dest
|
||||||
|
self.save()
|
||||||
|
except Exception:
|
||||||
|
string = "Cannot set destination: "
|
||||||
|
string += "%s is not a valid destination."
|
||||||
|
self.msg(string % destination)
|
||||||
|
logger.log_trace(string)
|
||||||
|
raise
|
||||||
|
#@destination.deleter
|
||||||
|
def destination_del(self):
|
||||||
|
"Deleter. Allows for del self.destination"
|
||||||
|
self.db_destination = None
|
||||||
|
self.save()
|
||||||
|
destination = property(destination_get, destination_set, destination_del)
|
||||||
|
|
||||||
#@property for consistent aliases access throughout Evennia
|
#@property for consistent aliases access throughout Evennia
|
||||||
#@aliases.setter
|
#@aliases.setter
|
||||||
def aliases_set(self, aliases):
|
def aliases_set(self, aliases):
|
||||||
|
|
@ -462,10 +506,10 @@ class ObjectDB(TypedObject):
|
||||||
def exits_get(self):
|
def exits_get(self):
|
||||||
"""
|
"""
|
||||||
Returns all exits from this object, i.e. all objects
|
Returns all exits from this object, i.e. all objects
|
||||||
at this location having the property _destination.
|
at this location having the property destination != None.
|
||||||
"""
|
"""
|
||||||
return [exi for exi in self.contents
|
return [exi for exi in self.contents
|
||||||
if exi.has_attribute('_destination')]
|
if exi.destination]
|
||||||
exits = property(exits_get)
|
exits = property(exits_get)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -589,8 +633,8 @@ class ObjectDB(TypedObject):
|
||||||
Moves this object to a new location.
|
Moves this object to a new location.
|
||||||
|
|
||||||
destination: (Object) Reference to the object to move to. This
|
destination: (Object) Reference to the object to move to. This
|
||||||
can also be an exit object, in which case the _destination
|
can also be an exit object, in which case the destination
|
||||||
attribute is used as destination.
|
property is used as destination.
|
||||||
quiet: (bool) If true, don't emit left/arrived messages.
|
quiet: (bool) If true, don't emit left/arrived messages.
|
||||||
emit_to_obj: (Object) object to receive error messages
|
emit_to_obj: (Object) object to receive error messages
|
||||||
"""
|
"""
|
||||||
|
|
@ -601,9 +645,9 @@ class ObjectDB(TypedObject):
|
||||||
if not destination:
|
if not destination:
|
||||||
emit_to_obj.msg("The destination doesn't exist.")
|
emit_to_obj.msg("The destination doesn't exist.")
|
||||||
return
|
return
|
||||||
if destination.has_attribute('_destination'):
|
if destination.destination:
|
||||||
# traverse exits
|
# traverse exits
|
||||||
destination = destination.get_attribute('_destination')
|
destination = destination.destination
|
||||||
|
|
||||||
# Before the move, call eventual pre-commands.
|
# Before the move, call eventual pre-commands.
|
||||||
try:
|
try:
|
||||||
|
|
@ -689,8 +733,7 @@ class ObjectDB(TypedObject):
|
||||||
"""
|
"""
|
||||||
for out_exit in self.exits:
|
for out_exit in self.exits:
|
||||||
out_exit.delete()
|
out_exit.delete()
|
||||||
for in_exit in \
|
for in_exit in ObjectDB.objects.filter(db_destination=self):
|
||||||
ObjectDB.objects.get_objs_with_attr_match('_destination', self):
|
|
||||||
in_exit.delete()
|
in_exit.delete()
|
||||||
|
|
||||||
def clear_contents(self):
|
def clear_contents(self):
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ class Object(TypeClass):
|
||||||
loc_name = self.location.name
|
loc_name = self.location.name
|
||||||
dest_name = destination.name
|
dest_name = destination.name
|
||||||
string = "%s is leaving %s, heading for %s."
|
string = "%s is leaving %s, heading for %s."
|
||||||
self.location.emit_to_contents(string % (name, loc_name, dest_name), exclude=self)
|
self.location.msg_contents(string % (name, loc_name, dest_name), exclude=self)
|
||||||
|
|
||||||
def announce_move_to(self, source_location):
|
def announce_move_to(self, source_location):
|
||||||
"""
|
"""
|
||||||
|
|
@ -143,7 +143,7 @@ class Object(TypeClass):
|
||||||
# This was created from nowhere and added to a player's
|
# This was created from nowhere and added to a player's
|
||||||
# inventory; it's probably the result of a create command.
|
# inventory; it's probably the result of a create command.
|
||||||
string = "You now have %s in your possession." % name
|
string = "You now have %s in your possession." % name
|
||||||
self.location.emit_to(string)
|
self.location.msg(string)
|
||||||
return
|
return
|
||||||
|
|
||||||
src_name = "nowhere"
|
src_name = "nowhere"
|
||||||
|
|
@ -151,7 +151,7 @@ class Object(TypeClass):
|
||||||
if source_location:
|
if source_location:
|
||||||
src_name = source_location.name
|
src_name = source_location.name
|
||||||
string = "%s arrives to %s from %s."
|
string = "%s arrives to %s from %s."
|
||||||
self.location.emit_to_contents(string % (name, loc_name, src_name), exclude=self)
|
self.location.msg_contents(string % (name, loc_name, src_name), exclude=self)
|
||||||
|
|
||||||
|
|
||||||
def at_after_move(self, source_location):
|
def at_after_move(self, source_location):
|
||||||
|
|
@ -203,7 +203,7 @@ class Object(TypeClass):
|
||||||
if content == pobject:
|
if content == pobject:
|
||||||
continue
|
continue
|
||||||
name = content.name
|
name = content.name
|
||||||
if content.attr('_destination'):
|
if content.destination:
|
||||||
exits.append(name)
|
exits.append(name)
|
||||||
elif content.has_player:
|
elif content.has_player:
|
||||||
users.append(name)
|
users.append(name)
|
||||||
|
|
@ -360,12 +360,12 @@ class Exit(Object):
|
||||||
"""
|
"""
|
||||||
This is the base exit object - it connects a location
|
This is the base exit object - it connects a location
|
||||||
to another. What separates it from other objects
|
to another. What separates it from other objects
|
||||||
is that it has the '_destination' attribute defined.
|
is that it has the 'destination' property defined.
|
||||||
Note that _destination is the only identifier to
|
Note that property is the only identifier to
|
||||||
separate an exit from normal objects, so if _destination
|
separate an exit from normal objects, so if the property
|
||||||
is removed, it will be treated like any other object. This
|
is removed, it will be treated like any other object. This
|
||||||
also means that any object can be made an exit by setting
|
also means that any object can be made an exit by setting
|
||||||
the attribute _destination to a valid location
|
the property destination to a valid location
|
||||||
('Quack like a duck...' and so forth).
|
('Quack like a duck...' and so forth).
|
||||||
"""
|
"""
|
||||||
def basetype_setup(self):
|
def basetype_setup(self):
|
||||||
|
|
@ -379,13 +379,17 @@ class Exit(Object):
|
||||||
|
|
||||||
def at_object_creation(self):
|
def at_object_creation(self):
|
||||||
"""
|
"""
|
||||||
An example just for show; the _destination attribute
|
An example just for show; the destination property
|
||||||
is usually set at creation time, not as part of the class
|
is usually set at creation time, not as part of the class
|
||||||
definition (unless you want an entire class of exits
|
definition (unless you want an entire class of exits
|
||||||
all leadning to the same hard-coded place ...)
|
all leadning to the same hard-coded place ...)
|
||||||
"""
|
"""
|
||||||
# this is what makes it an exit
|
# having destination != None is what makes it an exit
|
||||||
self.attr("_destination", "None")
|
# (what's set here won't last)
|
||||||
|
if self.location:
|
||||||
|
self.destination = self.location
|
||||||
|
else:
|
||||||
|
self.destination = 2 # use limbo as a failsafe
|
||||||
|
|
||||||
def at_object_delete(self):
|
def at_object_delete(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
of database object having that typeclass set on themselves).
|
of database object having that typeclass set on themselves).
|
||||||
"""
|
"""
|
||||||
dbtotals = {}
|
dbtotals = {}
|
||||||
typeclass_paths = set(obj.db_typeclass_path for obj in self.all())
|
typeclass_paths = set(self.values_list('db_typeclass_path', flat=True))
|
||||||
for typeclass_path in typeclass_paths:
|
for typeclass_path in typeclass_paths:
|
||||||
dbtotals[typeclass_path] = \
|
dbtotals[typeclass_path] = \
|
||||||
self.filter(db_typeclass_path=typeclass_path).count()
|
self.filter(db_typeclass_path=typeclass_path).count()
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ def reload_modules():
|
||||||
# should never need to do that anyway). Updating src requires a server
|
# should never need to do that anyway). Updating src requires a server
|
||||||
# reboot. Modules in except_dirs are considered ok to reload despite being
|
# reboot. Modules in except_dirs are considered ok to reload despite being
|
||||||
# inside src/
|
# inside src/
|
||||||
protected_dirs = ('src.',) # note that these MUST be tuples!
|
protected_dirs = ('src.', 'django.', 'twisted.') # note that these MUST be tuples!
|
||||||
except_dirs = ('src.commands.default.',) # "
|
except_dirs = ('src.commands.default.',) # "
|
||||||
|
|
||||||
# flag 'dangerous' typeclasses (those which retain a memory
|
# flag 'dangerous' typeclasses (those which retain a memory
|
||||||
|
|
@ -95,7 +95,7 @@ def reload_modules():
|
||||||
# clean as much of the caches as we can
|
# clean as much of the caches as we can
|
||||||
cache = AppCache()
|
cache = AppCache()
|
||||||
cache.app_store = SortedDict()
|
cache.app_store = SortedDict()
|
||||||
cache.app_models = SortedDict()
|
#cache.app_models = SortedDict() # cannot clean this, it resets ContentTypes!
|
||||||
cache.app_errors = {}
|
cache.app_errors = {}
|
||||||
cache.handled = {}
|
cache.handled = {}
|
||||||
cache.loaded = False
|
cache.loaded = False
|
||||||
|
|
@ -129,7 +129,7 @@ def reload_modules():
|
||||||
else:
|
else:
|
||||||
cemit_info(" ... no modules could be (or needed to be) reloaded.")
|
cemit_info(" ... no modules could be (or needed to be) reloaded.")
|
||||||
|
|
||||||
# clean out cache dictionary of typeclasses, exits and channe
|
# clean out cache dictionary of typeclasses, exits and channels
|
||||||
typeclassmodels.reset()
|
typeclassmodels.reset()
|
||||||
exithandler.EXITHANDLER.clear()
|
exithandler.EXITHANDLER.clear()
|
||||||
channelhandler.CHANNELHANDLER.update()
|
channelhandler.CHANNELHANDLER.update()
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ def page_index(request):
|
||||||
# A QuerySet of the most recently connected players.
|
# A QuerySet of the most recently connected players.
|
||||||
recent_users = PlayerDB.objects.get_recently_connected_players()[:fpage_player_limit]
|
recent_users = PlayerDB.objects.get_recently_connected_players()[:fpage_player_limit]
|
||||||
|
|
||||||
exits = ObjectDB.objects.get_objs_with_attr('_destination')
|
exits = ObjectDB.objects.filter(db_destination__isnull=False)
|
||||||
rooms = [room for room in ObjectDB.objects.filter(db_home=None) if room not in exits]
|
rooms = [room for room in ObjectDB.objects.filter(db_home__isnull=True) if room not in exits]
|
||||||
|
|
||||||
pagevars = {
|
pagevars = {
|
||||||
"page_title": "Front Page",
|
"page_title": "Front Page",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue