evennia/src/utils/idmapper
2013-05-29 16:16:28 +02:00
..
__init__.py Trunk: Merged the Devel-branch (branches/griatch) into /trunk. This constitutes a major refactoring of Evennia. Development will now continue in trunk. See the wiki and the past posts to the mailing list for info. /Griatch 2010-08-29 18:46:58 +00:00
base.py Changed cache system to use Django's cache mechanism. Changed field caches to make use of Django signalling instead of custom caching calls (this should make the system consistent also when called from the webserver). Created a wrapper system for easily wrapping fields with a default wrapper (so as to not have to explicitly define the properties (such as objdb.key) which all just do the same thing - load from the field and make sure to call save(). 2013-05-29 16:16:28 +02:00
EVENNIA.txt Added new process-pool runner based on AMPoule (integrated into Evennia). 2012-09-02 10:10:22 +02:00
LICENSE Trunk: Merged the Devel-branch (branches/griatch) into /trunk. This constitutes a major refactoring of Evennia. Development will now continue in trunk. See the wiki and the past posts to the mailing list for info. /Griatch 2010-08-29 18:46:58 +00:00
manager.py Updated to a supported idmapper version. Added a method for calculating the cache usage of the idmapper, and tied it to the @system command. 2012-04-30 00:51:36 +02:00
models.py Trunk: Merged the Devel-branch (branches/griatch) into /trunk. This constitutes a major refactoring of Evennia. Development will now continue in trunk. See the wiki and the past posts to the mailing list for info. /Griatch 2010-08-29 18:46:58 +00:00
README.rst Updated to a supported idmapper version. Added a method for calculating the cache usage of the idmapper, and tied it to the @system command. 2012-04-30 00:51:36 +02:00
tests.py Trunk: Merged the Devel-branch (branches/griatch) into /trunk. This constitutes a major refactoring of Evennia. Development will now continue in trunk. See the wiki and the past posts to the mailing list for info. /Griatch 2010-08-29 18:46:58 +00:00

This fork of django-idmapper fixes some bugs that prevented the idmapper from
being used in many instances. In particular, the caching manager is now inherited
by SharedMemoryManager subclasses, and it is used when Django uses an automatic
manager (see http://docs.djangoproject.com/en/dev/topics/db/managers/#controlling-automatic-manager-types). This means access through foreign keys now uses
identity mapping.

Tested with Django version 1.2 alpha 1 SVN-12375.

My modifications are usually accompanied by comments marked with "CL:".

Django Identity Mapper
======================

A pluggable Django application which allows you to explicitally mark your models to use an identity mapping pattern. This will share instances of the same model in memory throughout your interpreter.

Please note, that deserialization (such as from the cache) will *not* use the identity mapper.

Usage
-----
To use the shared memory model you simply need to inherit from it (instead of models.Model). This enable all queries (and relational queries) to this model to use the shared memory instance cache, effectively creating a single instance for each unique row (based on primary key) in the queryset.

For example, if you want to simply mark all of your models as a SharedMemoryModel, you might as well just import it as models.
::

	from idmapper import models

	class MyModel(models.SharedMemoryModel):
	    name = models.CharField(...)

Because the system is isolated, you may mix and match SharedMemoryModels with regular Models. The module idmapper.models imports everything from django.db.models and only adds SharedMemoryModel, so you can simply replace your import of models from django.db.
::

	from idmapper import models

	class MyModel(models.SharedMemoryModel):
	    name = models.CharField(...)
	    fkey = models.ForeignKey('Other')

	class Other(models.Model):
	    name = models.CharField(...)

References
----------

Original code and concept: http://code.djangoproject.com/ticket/17