Commit graph

83 commits

Author SHA1 Message Date
Griatch
0dae03156c Some optimizations, cleanup and a few bugfixes. Just changing a spurious property retrieval in the typeclass removed an extra, pointless database query. 2012-09-18 01:03:35 +02:00
Griatch
c53a9b5770 Changed how Objects are searched, using proper Django Q objects instead of hack-y evals to build queries. This has lead to a number of changes to the ObjectDB manager search. Notably there is now no way to supply a "location" to either of the manager search methods anymore. Instead you can now supply the keyword "candidates", a list of objects which should be used to limit the search. This is much more generic than giving location. The higher-level search (like caller.search, reached from commands) have not changed its API, so commands should work the same unless you are using the manager backbone directly. This search function is now using location to create the "candidates" list. Some other things, like matching for "me" and "here" have also been moved up to a level were it can be easily overloaded. "me" and "here" etc were also moved under i18n.
As part of this overhaul I implemented the partial_matching algorithm originally asked for by user "Adam_ASE" over IRC. This will allow for (local-only) partial matching of objects. So "big black sword" will now be matched by "bi", "sword", "bi bla" and so on. The partial matcher sits in src.utils.utils.py if one wants to use it for something else.
2012-09-17 15:31:50 +02:00
Griatch
ffcf4b3c2f Added cache-resyncing to ProcPool. This makes sure to update all affected object caches
whenever the subprocess returns (this is potentially not good enough for long-running scripts,
will have to ponder that one). Made ProcPool work with MySQL (where it works much better). Tested and fixed many
small bugs.
2012-09-03 01:11:14 +02:00
Griatch
f68523cc22 Minor optimizations and some fixes to the dummyrunner. 2012-08-22 22:34:43 +02:00
Griatch
5117bd2a0a Minor fixes and reducing some sql calls in various managers. 2012-08-22 16:15:52 +02:00
Griatch
4edde61be4 Minor cleanups and a fix to manage.py that lead to a traceback if running without arguments. 2012-08-22 13:28:38 +02:00
Griatch
cc88d38ab6 Some optimizations towards speeding up getting the contents of a location. 2012-08-19 11:45:13 +02:00
Griatch
1dee271fc7 Removed a bug in property cache that disabled the cache if the property was null (e.g for player lookups) 2012-08-19 11:15:22 +02:00
Griatch
8a44daef7e Further changes to allow dbrefs to be 0. 2012-08-18 23:35:11 +02:00
Griatch
7dcfdc4d4b Fixed a minor typo in docstring for ObjectDB.__db_get: To view all Attributes one uses obj.db.all, not obj.db.all(). 2012-06-20 23:22:26 +02:00
Griatch
3d24ee2242 Added a secure_attr() method to the base typeclass. This allows for system to access attributes with full access control (since it requires an accessing_obj as argument). This relies on (by default unused) lock types "readattr" (reading/listing the attr value), "editattr" (editing/deleting the attribute) and finally "createattr" for creating a new attribute. The first two checks are done directly on the Attribute class whereas the createattr check is done on the TypedObject on which the Attribute is to be stored. 2012-06-10 21:46:00 +02:00
Griatch
2dba8ad547 Changed attribute-caching to use a string as key rather than the attribute-object itself. The latter caused the database to be invoked in order to create the hash over and over. 2012-04-28 14:47:11 +02:00
Griatch
3091587e33 Added a timeout to the attribute caching; the system will now clean cache at regular intervals once it pass a certain size defined in settings. 2012-04-28 00:37:36 +02:00
Griatch
e3ce0a7933 Some fixes to the caching, particularly in set_attribute. 2012-04-27 00:03:31 +02:00
Griatch
9d970ea7c5 Added full caching to all attributes on a per-object level. This speeds up attribute loading considerably. 2012-04-26 21:39:16 +02:00
Griatch
6e08c011a1 Further caching and optimization, making some operations noticeable faster in the end. 2012-04-26 17:47:25 +02:00
Griatch
1a6ef5d983 Added more caching to channelhandler as well as players in order to cut back on unnecessary database calls. 2012-04-26 13:38:34 +02:00
Griatch
8c3b49e704 Changed how the Typeclass system returns errors. Instead of echoing typeclass erros to the MUD-info channel (which is not only not only very spammy for everyone but also very hard to make clean so as to avoid recursion at a stage of typeclass failing), the system instead stores a property on itself called 'typeclass_last_errmsg' that holds eventual errors. This means that the task of reporting errors does not fall on the typeclass system itself but on the calling methods, as it should be. So src.utils.create.create_* functions now takes a new optional keyword "report_to" that holds an object to receive errors. If this keyword is given, the function msg():es that object with the error and returns None as before. If report_to is not set however, the create_* methods now return an Exception containing the error text. All default commands have been changed to accomodate for this behaviour, which allows for much more control over errors.
Also, the default ADMIN_MEDIA static files changed location in Django 1.4. The initial_setup function now accounts for this.
2012-04-21 16:15:37 +02:00
Griatch
464aa8ca9e Added the ability to clear an object from the global cache. This is rarely
needed (and can be potentially dangerous if the object depends on certain
startup methods to run and/or holds temporary attributes on themselves -
these will all be lost due to a new instance being created. It is hoever
necessary when it comes to renaming Exits - since the Command on the exit
must then change name too, recaching the Exit will also update the command.
Resolves issue 223.
2012-04-15 21:46:43 +02:00
Griatch
c8df141e89 Further cleanup of source; making class methods _private for clarity in the API. 2012-03-31 15:09:22 +02:00
Griatch
fc156b5a54 Continuing work on API, making local-use class properties _private to make things easier to explore. 2012-03-31 13:06:29 +02:00
Griatch
c0322c9eae Cleaning some unnecessary whitespace, overall cleanup of various source codes. 2012-03-30 23:47:22 +02:00
Griatch
d4c97d7df8 Fixed a caching issue with TypedAttributes. 2012-03-29 20:30:35 +02:00
Griatch
82a10903d1 Added more comments to help exploration through the ev interface. 2012-03-29 19:42:08 +02:00
Griatch
da51cb063f ev-API cleanups. ev can now be imported also from a non-django initiated python interpreter (it initiates itself). Gave some more info text and made sure wrapped db_ methods correctly forward their doc strings for introspection. 2012-03-27 09:59:11 +02:00
Griatch
4398d42360 Added new templates to gamesrc/*/examples. The old base* modules still in place. Some cleanup of the API. 2012-03-25 16:35:22 +02:00
Griatch
0d01462077 Adding a new API system to Evennia. This centralizes all access of the evennia driver through a single module "ev". Importing ev one should be able to access (and also importantly, easily explore) Evennia's API much easier. This API goes a long way to "flatten" the structure so that one doesn't need to remember how to find some method in a deeply nested subdirectory.
As part of this work, I have also written full listings of all available properties on Typeclassed objects (including those inherited in various ways). Should hopefully make things easier to find.
One can of course still import things directly from src/ as before. But this is a first step towards removing the "base" objects in game/gamesrc and instead making those accessible through the core API.
2012-03-24 23:02:45 +01:00
Griatch
7a2cdd3842 Moved all command definitions of Typeclassed entities up one level, to Object, Player and Script respectively. The actual code is still on the models (ObjectDB, PlayerDB and ScriptDB), but one should not be able to use the methods without having to dig into the code as far. Also added extensive, up-to-date headers to the inheriting base objects in game/gamesrc. 2012-03-24 18:25:32 +01:00
Griatch
6a78fdafcb Removed a debug-print statement. 2012-03-13 01:39:30 +01:00
Griatch
ca280af659 Fixed cache issues with @type and @name commands that didn't properly update the cache when using them. 2012-03-13 01:37:28 +01:00
Griatch
42254fa3c4 Fixed an issue with creating new chars following the latest optimizations. 2012-02-26 19:04:57 +01:00
Griatch
018a98b92c Optimized typeclass conversion in typeclass manager. 2012-02-26 16:04:19 +01:00
Griatch
91f2a5930c Minor additions to typeclass loading. 2012-02-26 15:10:22 +01:00
Griatch
9660dd6656 Added caching to some more object properties. 2012-02-26 12:43:16 +01:00
Griatch
24c4791e9e Fixed a bug with the updating of the caching. 2012-02-26 01:10:20 +01:00
Griatch
1fa5791e19 Added aggressive caching for common typeclassed variables. 2012-02-25 23:37:50 +01:00
Griatch
9733a43a16 Fixed the issues with assigning to nested attribute-lists/dicts "in-situ", e.g. obj.db.mylist[1][2] = val. This now works as it should. I'm still not sure this behaviour is worth the fact that returning mylist from the attribute will actually return a nested structure of PackedLists/Dicts, and these will continue to save to the database whenever they are updated, also if not used in conjuction with db. Since this behaviour is what is already in the database, I'm committing this fix for the nested assignment error until I decide what to do about the other issue = val. This now works as it should. I'm still not sure this behaviour is worth the fact that returning mylist from the attribute will actually return a nested structure of PackedLists/Dicts, and these will continue to save to the database whenever they are updated, also if not used in conjuction with db. Since this behaviour is what is already in the database, I'm committing this fix for the nested assignment error until I decide what to do about the other issue.. 2012-02-24 23:22:38 +01:00
Griatch
3b88767865 Made fixes to the migrations. 2012-02-15 14:27:26 +01:00
Griatch
a32aebaa0e OBS- need to run migrations! Refactored attributes to use a slightly different internal storage format for faster access. Also set up caching of all attribute data, so subsequent reads of an attribute will not hit the database anymore, and writes will re-cache. 2012-02-14 23:40:16 +01:00
Griatch
42d502bfc6 OBS - Database schema has changed! If you use south, you need to run manage.py migrate!
This adds db indexing on a set of important database fields, all in the interest of optimization.
2012-02-06 13:18:25 +01:00
Griatch
7b2a4e4467 Cleaned up typeclasses, removing a lot of extranenous and ineffective code from the setattr/getattr methods that are called most often. 2012-02-05 21:04:10 +01:00
Griatch
2c4af9076d Made some commands sensible to the new form of obj.typeclass (it's not a typeclass instance, not a class). Changed the way TypedObject.swap_typeclass works, so as to properly manage failures. 2011-10-03 23:53:23 +02:00
Griatch
bc0195bbaa Worked with admin interface, cleaning up and adding functionality. There are still some strange behaviour that makes e.g. the presence of inlines to auto-create empty database objects for some strange reason. Inlines are turned off at the moment (so there is no convenient way to add attributes from the admin interface at this time). Creating players now work, but one needs to create all three components (User, Player, Character) in one go and tie them together. The User-admin form was changed to also support multi-word usernames (django default didn't allow spaces). 2011-10-02 22:37:07 +02:00
Griatch
7f2e6dd4fa Tidying up the admin interface by adding more verbose and helpful names to database fields as well as adding more help texts. The ObjectAdmin still gives tracebacks. 2011-10-02 01:21:03 +02:00
Griatch
23cd9e31b1 Restructured the way typeclasses are loaded. This makes it possible to run at_init() hooks at initiation also for objects without any custom cases for character/players. at_init() hooks are called only when an object is initiated. This means that a room's at_init() hook is only called when someone looks or enters it or a script operates on it, for example, rest of the time these objects are dormant, most efficiently. 2011-10-01 22:00:22 +02:00
Griatch
0a1bcd36c2 Removed FULL_PERSISTENCE setting. It was a "feature" that was added at a time when caching was more inefficient than now. Also the new reload mechanism make FULL_PERSISTENCE=False unfeasable. Use ndb explicitly for non-persistence. 2011-10-01 15:10:21 +02:00
Griatch
2597df0512 Last commit had a typo leading to startup traceback. 2011-09-20 20:26:35 +02:00
Griatch
18669c8700 Fixing so assigning to a nested attribute value doesn't loose data. It is unfortunately not possible to support direct assignment of deeply nested attributes at this time. So if obj.db.mydict = {1:{2:3}}, then obj.db.mydict[1] = 1 will work just fine, but obj.db.mydict[1][2] = 4 will not. For more advanced manipulation such as the latter case, store the dict in a temporary variable and save it back after changes have been done. 2011-09-20 19:59:08 +02:00
Griatch
058f8a9519 Fixed a bug in creating fresh dict-attributes/lists in the new attribute-save system. Resolves issue 191. 2011-09-20 15:55:58 +02:00
Griatch
475361ad28 Added functionality to Attributes to store and update dicts and lists dynamically. One side effect of this is that dicts and tuples need to be stored as custom object types which means that e.g. isintance(obj.db.mylist) == type(list) will return False. In order to do checks like this, use src.utils.utils.inherits_from() instead. The Attribute system now also supports tuples. All other iterables except dicts, lists and tuples are stored and retrieved as lists, same as before.
This fixes issue 189.
2011-09-20 12:37:45 +02:00