evennia.typeclasses.managers

This implements the common managers that are used by the abstract models in dbobjects.py (and which are thus shared by all Attributes and TypedObjects).

class evennia.typeclasses.managers.TypedObjectManager(*args, **kwargs)[源代码]

基类:evennia.utils.idmapper.manager.SharedMemoryManager

Common ObjectManager for all dbobjects.

get_attribute(key=None, category=None, value=None, strvalue=None, obj=None, attrtype=None, **kwargs)[源代码]

Return Attribute objects by key, by category, by value, by strvalue, by object (it is stored on) or with a combination of those criteria.

参数
  • key (str, optional) – The attribute’s key to search for

  • category (str, optional) – The category of the attribute(s) to search for.

  • value (str, optional) – The attribute value to search for. Note that this is not a very efficient operation since it will query for a pickled entity. Mutually exclusive to strvalue.

  • strvalue (str, optional) – The str-value to search for. Most Attributes will not have strvalue set. This is mutually exclusive to the value keyword and will take precedence if given.

  • obj (Object, optional) – On which object the Attribute to search for is.

  • attrype (str, optional) – An attribute-type to search for. By default this is either None (normal Attributes) or “nick”.

  • **kwargs (any) – Currently unused. Reserved for future use.

返回

list – The matching Attributes.

get_nick(key=None, category=None, value=None, strvalue=None, obj=None)[源代码]

Get a nick, in parallel to get_attribute.

参数
  • key (str, optional) – The nicks’s key to search for

  • category (str, optional) – The category of the nicks(s) to search for.

  • value (str, optional) – The attribute value to search for. Note that this is not a very efficient operation since it will query for a pickled entity. Mutually exclusive to strvalue.

  • strvalue (str, optional) – The str-value to search for. Most Attributes will not have strvalue set. This is mutually exclusive to the value keyword and will take precedence if given.

  • obj (Object, optional) – On which object the Attribute to search for is.

返回

nicks (list) – The matching Nicks.

get_by_attribute(key=None, category=None, value=None, strvalue=None, attrtype=None, **kwargs)[源代码]

Return objects having attributes with the given key, category, value, strvalue or combination of those criteria.

参数
  • key (str, optional) – The attribute’s key to search for

  • category (str, optional) – The category of the attribute to search for.

  • value (str, optional) – The attribute value to search for. Note that this is not a very efficient operation since it will query for a pickled entity. Mutually exclusive to strvalue.

  • strvalue (str, optional) – The str-value to search for. Most Attributes will not have strvalue set. This is mutually exclusive to the value keyword and will take precedence if given.

  • attrype (str, optional) – An attribute-type to search for. By default this is either None (normal Attributes) or “nick”.

  • kwargs (any) – Currently unused. Reserved for future use.

返回

obj (list) – Objects having the matching Attributes.

get_by_nick(key=None, nick=None, category='inputline')[源代码]

Get object based on its key or nick.

参数
  • key (str, optional) – The attribute’s key to search for

  • nick (str, optional) – The nickname to search for

  • category (str, optional) – The category of the nick to search for.

返回

obj (list) – Objects having the matching Nicks.

get_tag(key=None, category=None, obj=None, tagtype=None, global_search=False)[源代码]

Return Tag objects by key, by category, by object (it is stored on) or with a combination of those criteria.

参数
  • key (str, optional) – The Tag’s key to search for

  • category (str, optional) – The Tag of the attribute(s) to search for.

  • obj (Object, optional) – On which object the Tag to search for is.

  • tagtype (str, optional) – One of None (normal tags), “alias” or “permission”

  • global_search (bool, optional) – Include all possible tags, not just tags on this object

返回

tag (list) – The matching Tags.

get_permission(key=None, category=None, obj=None)[源代码]

Get a permission from the database.

参数
  • key (str, optional) – The permission’s identifier.

  • category (str, optional) – The permission’s category.

  • obj (object, optional) – The object on which this Tag is set.

返回

permission (list) – Permission objects.

get_alias(key=None, category=None, obj=None)[源代码]

Get an alias from the database.

参数
  • key (str, optional) – The permission’s identifier.

  • category (str, optional) – The permission’s category.

  • obj (object, optional) – The object on which this Tag is set.

返回

alias (list) – Alias objects.

get_by_tag(key=None, category=None, tagtype=None, **kwargs)[源代码]

Return objects having tags with a given key or category or combination of the two. Also accepts multiple tags/category/tagtype

参数
  • key (str or list, optional) – Tag key or list of keys. Not case sensitive.

  • category (str or list, optional) – Tag category. Not case sensitive. If key is a list, a single category can either apply to all keys in that list or this must be a list matching the key list element by element. If no key is given, all objects with tags of this category are returned.

  • tagtype (str, optional) – ‘type’ of Tag, by default this is either None (a normal Tag), alias or permission. This always apply to all queried tags.

关键字参数

match (str) – “all” (default) or “any”; determines whether the target object must be tagged with ALL of the provided tags/categories or ANY single one. ANY will perform a weighted sort, so objects with more tag matches will outrank those with fewer tag matches.

返回

objects (list) – Objects with matching tag.

引发

IndexError – If key and category are both lists and category is shorter than key.

get_by_permission(key=None, category=None)[源代码]

Return objects having permissions with a given key or category or combination of the two.

参数
  • key (str, optional) – Permissions key. Not case sensitive.

  • category (str, optional) – Permission category. Not case sensitive.

返回

objects (list) – Objects with matching permission.

get_by_alias(key=None, category=None)[源代码]

Return objects having aliases with a given key or category or combination of the two.

参数
  • key (str, optional) – Alias key. Not case sensitive.

  • category (str, optional) – Alias category. Not case sensitive.

返回

objects (list) – Objects with matching alias.

create_tag(key=None, category=None, data=None, tagtype=None)[源代码]

Create a new Tag of the base type associated with this object. This makes sure to create case-insensitive tags. If the exact same tag configuration (key+category+tagtype+dbmodel) exists on the model, a new tag will not be created, but an old one returned.

参数
  • key (str, optional) – Tag key. Not case sensitive.

  • category (str, optional) – Tag category. Not case sensitive.

  • data (str, optional) – Extra information about the tag.

  • tagtype (str or None, optional) – ‘type’ of Tag, by default this is either None (a normal Tag), alias or permission.

提示

The data field is not part of the uniqueness of the tag: Setting data on an existing tag will overwrite the old data field. It is intended only as a way to carry information about the tag (like a help text), not to carry any information about the tagged objects themselves.

dbref(dbref, reqhash=True)[源代码]

Determing if input is a valid dbref.

参数
  • dbref (str or int) – A possible dbref.

  • reqhash (bool, optional) – If the “#” is required for this to be considered a valid hash.

返回

dbref (int or None) – The integer part of the dbref.

提示

Valid forms of dbref (database reference number) are either a string ‘#N’ or an integer N.

get_id(dbref)[源代码]

Find object with given dbref.

参数

dbref (str or int) – The id to search for.

返回

object (TypedObject) – The matched object.

Alias to get_id.

参数

dbref (str or int) – The id to search for.

返回

Queryset – Queryset with 0 or 1 match.

search_dbref(dbref)

Alias to get_id.

参数

dbref (str or int) – The id to search for.

返回

Queryset – Queryset with 0 or 1 match.

get_dbref_range(min_dbref=None, max_dbref=None)[源代码]

Get objects within a certain range of dbrefs.

参数
  • min_dbref (int) – Start of dbref range.

  • max_dbref (int) – End of dbref range (inclusive)

返回

objects (list)

TypedObjects with dbrefs within

the given dbref ranges.

get_typeclass_totals(*args, **kwargs) → object[源代码]

Returns a queryset of typeclass composition statistics.

返回

qs (Queryset)

A queryset of dicts containing the typeclass (name),

the count of objects with that typeclass and a float representing the percentage of objects associated with the typeclass.

object_totals()[源代码]

Get info about database statistics.

返回

census (dict)

A dictionary {typeclass_path: number, …} with

all the typeclasses active in-game as well as the number of such objects defined (i.e. the number of database object having that typeclass set on themselves).

Searches through all objects returning those which are of the specified typeclass.

参数
  • typeclass (str or class) – A typeclass class or a python path to a typeclass.

  • include_children (bool, optional) – Return objects with given typeclass and all children inheriting from this typeclass. Mutually exclusive to include_parents.

  • include_parents (bool, optional) – Return objects with given typeclass and all parents to this typeclass. Mutually exclusive to include_children.

返回

objects (list) – The objects found with the given typeclasses.

引发

ImportError – If the provided typeclass is not a valid typeclass or the path to an existing typeclass.