New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Manager methods to return querysets rather than lists #1206

Closed
Griatch opened this Issue Feb 10, 2017 · 1 comment

Comments

Projects
1 participant
@Griatch
Member

Griatch commented Feb 10, 2017

Brief summary of issue / Description of requested feature:

Today, many of Evennia's custom managers (such as Objectdb.objects.get_objs_with_attr) will return a list rather than a Django queryset. Most of the time this doesn't matter, but it does matter when it comes to building custom queries - a list cannot be combined with a further query.

This feature request proposes to make all manager methods return querysets the same way Django's normal manager methods do.

Reasons for adding feature:

The original reason for Evennia's manager methods returning lists/individual objects was that Evennia's Typeclass system was separate from Django models - hence the managers must all make sure to return typeclasses rather than dbobjects. To this end, the managers all processed the returned database objects and converted them safely to lists of Typeclasses before returning. These days however, typeclasses are proxy models and the normal database operations return them directly. No conversion is needed and instead it's them being returned as lists that is the problem.

Pros:

  • This makes Evennia's managers more usable in combination with Django's other normal query operations like filter, exclude etc.
  • It makes Evennia managers directly useful for Django power users which today may have to cook their own solutions.

Cons:

  • A queryset is not a list, so if code is using the manager method and tries to, say, append to it, this will not work (they'll have to call list() on it first).

Extra information, such as Evennia revision/repo/branch, operating system and ideas for how to solve / implement:

This is a big enough API change that it will go into the devel branch leading up to Evennia 0.7.

@Griatch

This comment has been minimized.

Show comment
Hide comment
@Griatch

Griatch Feb 10, 2017

Member

This is also thematically connected to #1154.

Member

Griatch commented Feb 10, 2017

This is also thematically connected to #1154.

@Griatch Griatch changed the title from Feature Request: Change manager methods to return querysets rather than lists to Feature Request: Manager methods to return querysets rather than lists Feb 10, 2017

@Griatch Griatch moved this from TODO to In progress on devel branch in Evennia 0.7 Apr 19, 2017

@Griatch Griatch moved this from In progress on devel branch to Done on devel branch in Evennia 0.7 Apr 20, 2017

@Griatch Griatch added the implemented label Jul 18, 2017

@Griatch Griatch closed this in cf77d90 Sep 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment