diff --git a/src/objects/migrations/0017_rename_default_cmdsets.py b/src/objects/migrations/0017_rename_default_cmdsets.py index 2a3d93d5e4..adf98919b5 100644 --- a/src/objects/migrations/0017_rename_default_cmdsets.py +++ b/src/objects/migrations/0017_rename_default_cmdsets.py @@ -6,6 +6,7 @@ from django.db import models class Migration(DataMigration): + depends_on = (('players', '0014_add_attr__playable_characters'),) def forwards(self, orm): "Write your forwards methods here." # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." diff --git a/src/objects/migrations/0021_auto__del_objattribute.py b/src/objects/migrations/0021_auto__del_objattribute.py new file mode 100644 index 0000000000..b6377a22ea --- /dev/null +++ b/src/objects/migrations/0021_auto__del_objattribute.py @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Deleting model 'ObjAttribute' + db.delete_table(u'objects_objattribute') + + # Adding M2M table for field db_attributes on 'ObjectDB' + db.create_table(u'objects_objectdb_db_attributes', ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('objectdb', models.ForeignKey(orm[u'objects.objectdb'], null=False)), + ('attribute', models.ForeignKey(orm[u'typeclasses.attribute'], null=False)) + )) + db.create_unique(u'objects_objectdb_db_attributes', ['objectdb_id', 'attribute_id']) + + + def backwards(self, orm): + # Adding model 'ObjAttribute' + db.create_table(u'objects_objattribute', ( + ('db_lock_storage', self.gf('django.db.models.fields.TextField')(blank=True)), + ('db_value2', self.gf('src.utils.picklefield.PickledObjectField')(null=True)), + ('db_date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + ('db_key', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), + ('db_obj', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['objects.ObjectDB'])), + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal('objects', ['ObjAttribute']) + + # Removing M2M table for field db_attributes on 'ObjectDB' + db.delete_table('objects_objectdb_db_attributes') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'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'}), + u'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'}) + }, + u'objects.alias': { + 'Meta': {'object_name': 'Alias'}, + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['objects.ObjectDB']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'objects.objectdb': { + 'Meta': {'object_name': 'ObjectDB'}, + 'db_attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['typeclasses.Attribute']", 'null': 'True', 'symmetrical': 'False'}), + 'db_cmdset_storage': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': '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': u"orm['objects.ObjectDB']"}), + 'db_home': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'homes_set'", 'null': 'True', 'to': u"orm['objects.ObjectDB']"}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_location': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locations_set'", 'null': 'True', 'to': u"orm['objects.ObjectDB']"}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_player': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['players.PlayerDB']", 'null': 'True', 'blank': 'True'}), + 'db_sessid': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'objects.objectnick': { + 'Meta': {'unique_together': "(('db_nick', 'db_type', 'db_obj'),)", 'object_name': 'ObjectNick'}, + 'db_nick': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"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'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'players.playerdb': { + 'Meta': {'object_name': 'PlayerDB'}, + 'db_attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['typeclasses.Attribute']", 'null': 'True', 'symmetrical': 'False'}), + 'db_cmdset_storage': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'db_is_connected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'unique': 'True'}) + }, + u'typeclasses.attribute': { + 'Meta': {'object_name': 'Attribute'}, + '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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['objects'] \ No newline at end of file diff --git a/src/objects/models.py b/src/objects/models.py index 49cb8609ec..ca6cec98a9 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -56,15 +56,15 @@ _HERE = _("here") #------------------------------------------------------------ -class ObjAttribute(Attribute): - "Attributes for ObjectDB objects." - db_obj = models.ForeignKey("ObjectDB") - - class Meta: - "Define Django meta options" - verbose_name = "Object Attribute" - verbose_name_plural = "Object Attributes" - +#class ObjAttribute(Attribute): +# "Attributes for ObjectDB objects." +# db_obj = models.ForeignKey("ObjectDB") +# +# class Meta: +# "Define Django meta options" +# verbose_name = "Object Attribute" +# verbose_name_plural = "Object Attributes" +# # attach the cache handlers #post_init.connect(attr_post_init, sender=ObjAttribute, dispatch_uid="objattrcache") #pre_delete.connect(attr_pre_delete, sender=ObjAttribute, dispatch_uid="objattrcache") diff --git a/src/players/migrations/0008_converting_attributes.py b/src/players/migrations/0008_converting_attributes.py index d7d91294fd..a970b07e26 100644 --- a/src/players/migrations/0008_converting_attributes.py +++ b/src/players/migrations/0008_converting_attributes.py @@ -10,7 +10,6 @@ except ImportError: import pickle from src.utils.utils import to_str, to_unicode #from src.typeclasses.models import PackedDBobject,PackedDict,PackedList -from src.players.models import PlayerAttribute from django.contrib.contenttypes.models import ContentType CTYPEGET = ContentType.objects.get @@ -370,7 +369,7 @@ class Migration(DataMigration): def forwards(self, orm): "Write your forwards methods here." - for attr in orm.PlayerAttribute.objects.all(): + for attr in orm['players.PlayerAttribute'].objects.all(): try: # repack attr into new format, and reimport val = pickle.loads(to_str(attr.db_value)) diff --git a/src/players/migrations/0009_converting_attributes.py b/src/players/migrations/0009_converting_attributes.py index 3d2ddd083d..fbb4c4bd68 100644 --- a/src/players/migrations/0009_converting_attributes.py +++ b/src/players/migrations/0009_converting_attributes.py @@ -10,7 +10,6 @@ except ImportError: import pickle from src.utils.utils import to_str, to_unicode #from src.typeclasses.models import PackedDBobject -from src.players.models import PlayerAttribute from django.contrib.contenttypes.models import ContentType CTYPEGET = ContentType.objects.get @@ -259,7 +258,7 @@ class Migration(DataMigration): def forwards(self, orm): "Write your forwards methods here." - for attr in orm.PlayerAttribute.objects.all(): + for attr in orm['players.PlayerAttribute'].objects.all(): try: # repack attr into new format, and reimport val = pickle.loads(to_str(attr.db_value)) diff --git a/src/players/migrations/0020_auto__del_playerattribute.py b/src/players/migrations/0020_auto__del_playerattribute.py new file mode 100644 index 0000000000..d58c9324df --- /dev/null +++ b/src/players/migrations/0020_auto__del_playerattribute.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Deleting model 'PlayerAttribute' + db.delete_table(u'players_playerattribute') + + # Adding M2M table for field db_attributes on 'PlayerDB' + db.create_table(u'players_playerdb_db_attributes', ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('playerdb', models.ForeignKey(orm[u'players.playerdb'], null=False)), + ('attribute', models.ForeignKey(orm[u'typeclasses.attribute'], null=False)) + )) + db.create_unique(u'players_playerdb_db_attributes', ['playerdb_id', 'attribute_id']) + + + def backwards(self, orm): + # Adding model 'PlayerAttribute' + db.create_table(u'players_playerattribute', ( + ('db_lock_storage', self.gf('django.db.models.fields.TextField')(blank=True)), + ('db_value2', self.gf('src.utils.picklefield.PickledObjectField')(null=True)), + ('db_date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + ('db_key', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), + ('db_obj', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['players.PlayerDB'])), + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal('players', ['PlayerAttribute']) + + # Removing M2M table for field db_attributes on 'PlayerDB' + db.delete_table('players_playerdb_db_attributes') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'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'}), + u'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'}) + }, + u'players.playerdb': { + 'Meta': {'object_name': 'PlayerDB'}, + 'db_attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['typeclasses.Attribute']", 'null': 'True', 'symmetrical': 'False'}), + 'db_cmdset_storage': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'db_is_connected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'unique': 'True'}) + }, + u'players.playernick': { + 'Meta': {'unique_together': "(('db_nick', 'db_type', 'db_obj'),)", 'object_name': 'PlayerNick'}, + 'db_nick': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['players.PlayerDB']"}), + 'db_real': ('django.db.models.fields.TextField', [], {}), + 'db_type': ('django.db.models.fields.CharField', [], {'default': "'inputline'", 'max_length': '16', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'typeclasses.attribute': { + 'Meta': {'object_name': 'Attribute'}, + '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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['players'] \ No newline at end of file diff --git a/src/players/models.py b/src/players/models.py index 54cbac5214..aa86123d82 100644 --- a/src/players/models.py +++ b/src/players/models.py @@ -64,18 +64,18 @@ _TYPECLASS = None # #------------------------------------------------------------ -class PlayerAttribute(Attribute): - """ - PlayerAttributes work the same way as Attributes on game objects, - but are intended to store OOC information specific to each user - and game (example would be configurations etc). - """ - db_obj = models.ForeignKey("PlayerDB") - - class Meta: - "Define Django meta options" - verbose_name = "Player Attribute" - +#class PlayerAttribute(Attribute): +# """ +# PlayerAttributes work the same way as Attributes on game objects, +# but are intended to store OOC information specific to each user +# and game (example would be configurations etc). +# """ +# db_obj = models.ForeignKey("PlayerDB") +# +# class Meta: +# "Define Django meta options" +# verbose_name = "Player Attribute" +# #post_init.connect(attr_post_init, sender=PlayerAttribute, dispatch_uid="playerattrcache") #pre_delete.connect(attr_pre_delete, sender=PlayerAttribute, dispatch_uid="playerattrcache") diff --git a/src/scripts/migrations/0013_auto__del_scriptattribute.py b/src/scripts/migrations/0013_auto__del_scriptattribute.py new file mode 100644 index 0000000000..2b74eddb9d --- /dev/null +++ b/src/scripts/migrations/0013_auto__del_scriptattribute.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Deleting model 'ScriptAttribute' + db.delete_table(u'scripts_scriptattribute') + + # Adding M2M table for field db_attributes on 'ScriptDB' + db.create_table(u'scripts_scriptdb_db_attributes', ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('scriptdb', models.ForeignKey(orm[u'scripts.scriptdb'], null=False)), + ('attribute', models.ForeignKey(orm[u'typeclasses.attribute'], null=False)) + )) + db.create_unique(u'scripts_scriptdb_db_attributes', ['scriptdb_id', 'attribute_id']) + + + def backwards(self, orm): + # Adding model 'ScriptAttribute' + db.create_table(u'scripts_scriptattribute', ( + ('db_lock_storage', self.gf('django.db.models.fields.TextField')(blank=True)), + ('db_value2', self.gf('src.utils.picklefield.PickledObjectField')(null=True)), + ('db_date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + ('db_key', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), + ('db_obj', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['scripts.ScriptDB'])), + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal('scripts', ['ScriptAttribute']) + + # Removing M2M table for field db_attributes on 'ScriptDB' + db.delete_table('scripts_scriptdb_db_attributes') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'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'}), + u'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'}) + }, + u'objects.objectdb': { + 'Meta': {'object_name': 'ObjectDB'}, + 'db_attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['typeclasses.Attribute']", 'null': 'True', 'symmetrical': 'False'}), + 'db_cmdset_storage': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': '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': u"orm['objects.ObjectDB']"}), + 'db_home': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'homes_set'", 'null': 'True', 'to': u"orm['objects.ObjectDB']"}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_location': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locations_set'", 'null': 'True', 'to': u"orm['objects.ObjectDB']"}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_player': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['players.PlayerDB']", 'null': 'True', 'blank': 'True'}), + 'db_sessid': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'players.playerdb': { + 'Meta': {'object_name': 'PlayerDB'}, + 'db_attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['typeclasses.Attribute']", 'null': 'True', 'symmetrical': 'False'}), + 'db_cmdset_storage': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'db_is_connected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'unique': 'True'}) + }, + u'scripts.scriptdb': { + 'Meta': {'object_name': 'ScriptDB'}, + 'db_attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['typeclasses.Attribute']", 'null': 'True', 'symmetrical': 'False'}), + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'db_desc': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_interval': ('django.db.models.fields.IntegerField', [], {'default': '-1'}), + 'db_is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['objects.ObjectDB']", 'null': 'True', 'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_persistent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_repeats': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'db_start_delay': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'typeclasses.attribute': { + 'Meta': {'object_name': 'Attribute'}, + '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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['scripts'] \ No newline at end of file diff --git a/src/scripts/models.py b/src/scripts/models.py index e7f1b0efb9..f6b16e786b 100644 --- a/src/scripts/models.py +++ b/src/scripts/models.py @@ -40,15 +40,15 @@ __all__ = ("ScriptDB",) # #------------------------------------------------------------ -class ScriptAttribute(Attribute): - "Attributes for ScriptDB objects." - db_obj = models.ForeignKey("ScriptDB", verbose_name='script') - - class Meta: - "Define Django meta options" - verbose_name = "Script Attribute" - verbose_name_plural = "Script Attributes" - +#class ScriptAttribute(Attribute): +# "Attributes for ScriptDB objects." +# db_obj = models.ForeignKey("ScriptDB", verbose_name='script') +# +# class Meta: +# "Define Django meta options" +# verbose_name = "Script Attribute" +# verbose_name_plural = "Script Attributes" +# ## attach cache handlers for attribute lookup #post_init.connect(attr_post_init, sender=ScriptAttribute, dispatch_uid="scriptattrcache") #pre_delete.connect(attr_pre_delete, sender=ScriptAttribute, dispatch_uid="scriptattrcache") diff --git a/src/server/caches.py b/src/server/caches.py index 4bb790d098..8d36d1f9f8 100644 --- a/src/server/caches.py +++ b/src/server/caches.py @@ -91,7 +91,7 @@ def field_pre_save(sender, instance=None, update_fields=None, raw=False, **kwarg """ if raw: return - print "field_pre_save:", _GA(instance, "db_key") if hasattr(instance, "db_key") else instance, update_fields + print "field_pre_save:", _GA(instance, "db_key"), update_fields# if hasattr(instance, "db_key") else instance, update_fields if update_fields: # this is a list of strings at this point. We want field objects update_fields = (_GA(_GA(instance, "_meta"), "get_field_by_name")(field)[0] for field in update_fields) @@ -108,7 +108,10 @@ def field_pre_save(sender, instance=None, update_fields=None, raw=False, **kwarg handler = None #hid = hashid(instance, "-%s" % fieldname) if callable(handler): - old_value = _GA(instance, _GA(field, "get_cache_name")())#_FIELD_CACHE.get(hid) if hid else None + try: + old_value = _GA(instance, _GA(field, "get_cache_name")())#_FIELD_CACHE.get(hid) if hid else None + except AttributeError: + old_value=None # the handler may modify the stored value in various ways # don't catch exceptions, the handler must work! new_value = handler(new_value, old_value=old_value) diff --git a/src/server/migrations/0003_add_tmpattr.py b/src/server/migrations/0003_add_tmpattr.py new file mode 100644 index 0000000000..19b8019fd9 --- /dev/null +++ b/src/server/migrations/0003_add_tmpattr.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'TmpAttribute' + db.create_table(u'server_tmpattribute', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('db_key', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), + ('db_value', self.gf('src.utils.picklefield.PickledObjectField')(null=True)), + ('db_lock_storage', self.gf('django.db.models.fields.TextField')(blank=True)), + ('db_obj_id', self.gf('django.db.models.fields.IntegerField')(null=True)), + ('db_obj_type', self.gf('django.db.models.fields.CharField')(max_length=10, null=True)), + ('db_date_created', self.gf('django.db.models.fields.DateTimeField')(editable=True, auto_now_add=False)), + )) + db.send_create_signal('server', ['TmpAttribute']) + + + def backwards(self, orm): + # Deleting model 'TmpAttribute' + db.delete_table(u'server_tmpattribute') + + + models = { + u'server.serverconfig': { + 'Meta': {'object_name': 'ServerConfig'}, + 'db_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}), + 'db_value': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'server.tmpattribute': { + 'Meta': {'object_name': 'TmpAttribute'}, + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'db_obj_type': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'db_date_created':('django.db.models.fields.DateTimeField',[],{'editable':'True', 'auto_now_add':'True'}), + } + } + + complete_apps = ['server'] diff --git a/src/server/migrations/0004_store_all_attrs.py b/src/server/migrations/0004_store_all_attrs.py new file mode 100644 index 0000000000..39e2343e4c --- /dev/null +++ b/src/server/migrations/0004_store_all_attrs.py @@ -0,0 +1,208 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +#from src.utils.dbserialize import to_pickle, from_pickle + +class Migration(DataMigration): + "Store all attributes in a temporary table" + depends_on = (('objects', '0020_remove_old_attr_value_field'), + ('players','0019_remove_old_attr_value_field'), + ('scripts','0012_remove_old_attr_value_field')) + no_dry_run = True + def forwards(self, orm): + "Write your forwards methods here." + # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." + + # store ObjectAttributes + for attrobj in orm['objects.ObjAttribute'].objects.all(): + #value = from_pickle(attrobj.db_value, db_obj=attrobj) + new_attr = orm['server.TmpAttribute'](db_key=attrobj.db_key, + db_value=attrobj.db_value, + db_lock_storage=attrobj.db_lock_storage, + db_obj_id=attrobj.db_obj.id, + db_obj_type="objectdb", + db_date_created=attrobj.db_date_created) + new_attr.save() + #new_attr.db_value = to_pickle(value) + #new_attr.save() + + # store PlayerAttributes + for attrobj in orm['players.PlayerAttribute'].objects.all(): + #value = from_pickle(attrobj.db_value, db_obj=attrobj) + new_attr = orm['server.TmpAttribute'](db_key=attrobj.db_key, + db_value=attrobj.db_value, + db_lock_storage=attrobj.db_lock_storage, + db_obj_id=attrobj.db_obj.id, + db_obj_type="playerdb", + db_date_created=attrobj.db_date_created) + new_attr.save() + #new_attr.db_value = to_pickle(value) + #new_attr.save() + + # store ScriptAttributes + for attrobj in orm['scripts.ScriptAttribute'].objects.all(): + #value = from_pickle(attrobj.db_value, db_obj=attrobj) + new_attr = orm['server.TmpAttribute'](db_key=attrobj.db_key, + db_value=attrobj.db_value, + db_lock_storage=attrobj.db_lock_storage, + db_obj_id=attrobj.db_obj.id, + db_obj_type="scriptdb", + db_date_created=attrobj.db_date_created) + new_attr.save() + #new_attr.db_value = to_pickle(value) + #new_attr.save() + + def backwards(self, orm): + "Write your backwards methods here." + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'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'}), + u'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'}) + }, + u'objects.alias': { + 'Meta': {'object_name': 'Alias'}, + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['objects.ObjectDB']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['objects.ObjectDB']"}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'objects.objectdb': { + 'Meta': {'object_name': 'ObjectDB'}, + 'db_cmdset_storage': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': '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': u"orm['objects.ObjectDB']"}), + 'db_home': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'homes_set'", 'null': 'True', 'to': u"orm['objects.ObjectDB']"}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_location': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locations_set'", 'null': 'True', 'to': u"orm['objects.ObjectDB']"}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_player': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['players.PlayerDB']", 'null': 'True', 'blank': 'True'}), + 'db_sessid': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'objects.objectnick': { + 'Meta': {'unique_together': "(('db_nick', 'db_type', 'db_obj'),)", 'object_name': 'ObjectNick'}, + 'db_nick': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"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'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'players.playerattribute': { + 'Meta': {'object_name': 'PlayerAttribute'}, + '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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['players.PlayerDB']"}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'players.playerdb': { + 'Meta': {'object_name': 'PlayerDB'}, + 'db_cmdset_storage': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'db_is_connected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'unique': 'True'}) + }, + u'players.playernick': { + 'Meta': {'unique_together': "(('db_nick', 'db_type', 'db_obj'),)", 'object_name': 'PlayerNick'}, + 'db_nick': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['players.PlayerDB']"}), + 'db_real': ('django.db.models.fields.TextField', [], {}), + 'db_type': ('django.db.models.fields.CharField', [], {'default': "'inputline'", 'max_length': '16', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'scripts.scriptattribute': { + 'Meta': {'object_name': 'ScriptAttribute'}, + '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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['scripts.ScriptDB']"}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'scripts.scriptdb': { + 'Meta': {'object_name': 'ScriptDB'}, + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'db_desc': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_interval': ('django.db.models.fields.IntegerField', [], {'default': '-1'}), + 'db_is_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['objects.ObjectDB']", 'null': 'True', 'blank': 'True'}), + 'db_permissions': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'db_persistent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_repeats': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'db_start_delay': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'db_typeclass_path': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'server.serverconfig': { + 'Meta': {'object_name': 'ServerConfig'}, + 'db_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}), + 'db_value': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'server.tmpattribute': { + 'Meta': {'object_name': 'TmpAttribute'}, + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {'editable':'True','auto_now_add': 'False', 'blank': 'True'}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'db_obj_type': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['objects', 'players', 'scripts', 'server'] + symmetrical = True diff --git a/src/server/migrations/0005_auto__del_tmpattribute.py b/src/server/migrations/0005_auto__del_tmpattribute.py new file mode 100644 index 0000000000..7eab5ae376 --- /dev/null +++ b/src/server/migrations/0005_auto__del_tmpattribute.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + depends_on = (('typeclasses', '0002_resave_attrs'),) + + def forwards(self, orm): + # Deleting model 'TmpAttribute' + db.delete_table(u'server_tmpattribute') + + + def backwards(self, orm): + # Adding model 'TmpAttribute' + db.create_table(u'server_tmpattribute', ( + ('db_key', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), + ('db_obj_id', self.gf('django.db.models.fields.IntegerField')(null=True)), + ('db_obj_type', self.gf('django.db.models.fields.CharField')(max_length=10, null=True)), + ('db_value', self.gf('src.utils.picklefield.PickledObjectField')(null=True)), + ('db_date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=False, editable=True, blank=True)), + ('db_lock_storage', self.gf('django.db.models.fields.TextField')(blank=True)), + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal('server', ['TmpAttribute']) + + + models = { + u'server.serverconfig': { + 'Meta': {'object_name': 'ServerConfig'}, + 'db_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}), + 'db_value': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['server'] diff --git a/src/settings_default.py b/src/settings_default.py index 0187cc4c62..e055f5c66e 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -497,6 +497,7 @@ INSTALLED_APPS = ( 'django.contrib.admindocs', 'django.contrib.flatpages', 'src.server', + 'src.typeclasses', 'src.players', 'src.objects', 'src.comms', diff --git a/src/typeclasses/migrations/0001_initial.py b/src/typeclasses/migrations/0001_initial.py new file mode 100644 index 0000000000..bc6777daab --- /dev/null +++ b/src/typeclasses/migrations/0001_initial.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'Attribute' + db.create_table(u'typeclasses_attribute', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('db_key', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), + ('db_value', self.gf('src.utils.picklefield.PickledObjectField')(null=True)), + ('db_lock_storage', self.gf('django.db.models.fields.TextField')(blank=True)), + ('db_date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + )) + db.send_create_signal(u'typeclasses', ['Attribute']) + + + def backwards(self, orm): + # Deleting model 'Attribute' + db.delete_table(u'typeclasses_attribute') + + + models = { + u'typeclasses.attribute': { + 'Meta': {'object_name': 'Attribute'}, + '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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['typeclasses'] \ No newline at end of file diff --git a/src/typeclasses/migrations/0002_resave_attrs.py b/src/typeclasses/migrations/0002_resave_attrs.py new file mode 100644 index 0000000000..b869f51bab --- /dev/null +++ b/src/typeclasses/migrations/0002_resave_attrs.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models + +class Migration(DataMigration): + depends_on = (('server', '0003_add_tmpattr'),) + no_dry_run=True + def forwards(self, orm): + "Write your forwards methods here." + # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." + + for tmpattr in orm['server.TmpAttribute'].objects.all(): + typ = tmpattr.db_obj_type + dbid = tmpattr.db_obj_id + if typ == 'objectdb': + try: + dbobj = orm['objects.ObjectDB'].objects.get(dbid) + except: + print "could not find objid %i" % objid + continue + elif typ == 'playerdb': + try: + dbobj = orm['players.PlayerDB'].objects.get(dbid) + except: + print "could not find objid %i" % objid + continue + elif typ == 'scriptdb': + try: + dbobj = orm['scripts.ScriptDB'].objects.get(dbid) + except: + print "could not find objid %i" % objid + continue + else: + print "Wrong object type to store on: %s" % typ + continue + dbattr = orm['typeclasses.Attribute'].create(db_key=tmpattr.db_key, + db_value=tmpattr.db_value, + db_lock_storage=tmpattr.db_lock_storage, + db_date_created=tmpattr.db_date) + + dbattr.save() + dbobj.db_attributes.add(dbattr) + + + def backwards(self, orm): + "Write your backwards methods here." + raise RuntimeError("Cannot revert this migration.") + + models = { + u'server.serverconfig': { + 'Meta': {'object_name': 'ServerConfig'}, + 'db_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}), + 'db_value': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'server.tmpattribute': { + 'Meta': {'object_name': 'TmpAttribute'}, + 'db_date_created': ('django.db.models.fields.DateTimeField', [], {}), + 'db_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_obj_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'db_obj_type': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'typeclasses.attribute': { + 'Meta': {'object_name': 'Attribute'}, + '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_index': 'True'}), + 'db_lock_storage': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'db_value': ('src.utils.picklefield.PickledObjectField', [], {'null': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['server', 'typeclasses'] + symmetrical = True diff --git a/src/typeclasses/migrations/__init__.py b/src/typeclasses/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index 94c76420ff..335db20904 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -71,7 +71,6 @@ _DA = object.__delattr__ # #------------------------------------------------------------ - class Attribute(SharedMemoryModel): """ Abstract django model. @@ -88,34 +87,22 @@ class Attribute(SharedMemoryModel): mode - which type of data is stored in attribute lock_storage - perm strings obj - which object the attribute is defined on - date_created - when the attribute was created - value - the data stored in the attribute - what is actually stored in the field is a dict + date_created - when the attribute was created. + value - the data stored in the attribute, in pickled form + using wrappers to be able to store/retrieve models. - {type : nodb|dbobj|dbiter, - data : } - - where type is info for the loader, telling it if holds a single - dbobject (dbobj), have to do a full scan for dbrefs (dbiter) or - if it is a normal Python structure without any dbobjs inside it - and can thus return it without further action (nodb). """ # # Attribute Database Model setup # - # # These database fields are all set using their corresponding properties, # named same as the field, but withtout the db_* prefix. - db_key = models.CharField('key', max_length=255, db_index=True) # access through the value property db_value = PickledObjectField('value', null=True) # Lock storage db_lock_storage = models.TextField('locks', blank=True) - # references the object the attribute is linked to (this is set - # by each child class to this abstract class) - db_obj = None # models.ForeignKey("RefencedObject") #TODO-remove # time stamp db_date_created = models.DateTimeField('date_created', editable=False, auto_now_add=True) @@ -132,9 +119,9 @@ class Attribute(SharedMemoryModel): class Meta: "Define Django meta options" - #abstract = True verbose_name = "Evennia Attribute" + # Wrapper properties to easily set database fields. These are # @property decorators that allows to access these fields using # normal python operations (without having to remember to save() @@ -1003,7 +990,7 @@ class TypedObject(SharedMemoryModel): """ attr_obj = get_attr_cache(self, attribute_name) if not attr_obj: - attr_obj = _GA(self, "db_atttributes").filter(db_key__iexact=attribute_name) + attr_obj = _GA(self, "db_attributes").filter(db_key__iexact=attribute_name) if not attr_obj: if raise_exception: raise AttributeError @@ -1315,4 +1302,4 @@ class TypedObject(SharedMemoryModel): # connect to signal -m2m_changed.connect(update_attr_cache, sender=TypedObject.db_attributes.through) +#m2m_changed.connect(update_attr_cache, sender=TypedObject.db_attributes.through)