google-code-export / evennia

Automatically exported from code.google.com/p/evennia
Other
1 stars 0 forks source link

Feature suggestion: search by typeclass, and child typeclasses #405

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
A) Describe the suggested feature and how it is supposed to work and behave
to the end user (player or admin/coder).

TypedObjectManager.typeclass_search(typeclass, with_child_classes=?)

B) List briefly your arguments for why you think this new feature should be
included in Evennia.

This should be fairly evident, but in my particular immediate case, I have 
different kinds of exits (Some which can be claimed by users, sveral types of 
these, and some which let you beam to an auto-detected location, etc.) and I 
want to scan all of the auto-claimable ones to make sure that the claimer of 
the exit hasn't abandoned the game (and free it up if he has)

It would be inefficient for me to grab every single object in the database 
(Especially since my database is pretty big already thanks to the Latitude 
import, and bound to get bigger), and check their inheritance path.

C) If you have any suggestions on the best way to implement this new
feature, write those ideas below.

The existing typeclass_search call shows how this can be a pretty efficient 
process.  It just does a query filtering based on the typeclass name string.

To add this feature, I would suggest doing a query like this:
  select typeclass_path from table group by typeclass_path
(should be very fast, especially if there's an index on that field)

Then, ensure that each class is currently loaded.  After which time, you should 
be able to brew up a cache table of inheritance, which can be used to produce a 
list of typeclass paths.  Then typeclass_search could just go through each one 
of them, one by one, and return the amalgamated list.

Original issue reported on code.google.com by daniel@benoy.name on 21 Jul 2013 at 3:47

GoogleCodeExporter commented 9 years ago

Original comment by griatch on 21 Aug 2013 at 3:27