thoas / django-sequere Goto Github PK
View Code? Open in Web Editor NEWA Django application to implement a follow system and a timeline using multiple backends (db, redis, etc.)
License: MIT License
A Django application to implement a follow system and a timeline using multiple backends (db, redis, etc.)
License: MIT License
I create a timeline like:
class CommentAction(Action):
verb = "comment"
class ProfileSequere(ModelBase):
identifier = "profile"
actions = (CommentAction,)
register(Profile, ProfileSequere)
timeline = Timeline(profile)
timeline.save(CommentAction(actor=profile))
print(timeline.get_private())
On the get_private line it fails. get_private_count() actually works and returns the count.
pipe.execute()
returns []
Stacktrace
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
return self.application(environ, start_response)
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
response = self.get_response(request)
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 199, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.4/site-packages/django_extensions/management/technical_response.py", line 5, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.4/site-packages/six.py", line 659, in reraise
raise value
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.4/site-packages/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/views/decorators/http.py", line 41, in inner
return func(request, *args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/contrib/comments/views/comments.py", line 127, in post_comment
request=request
File "/usr/local/lib/python3.4/site-packages/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File "/code/core/views.py", line 39, in comment_activity
print(timeline.get_private())
File "/usr/local/lib/python3.4/site-packages/sequere/query.py", line 51, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/usr/local/lib/python3.4/site-packages/sequere/query.py", line 38, in __getitem__
return k.step and list(self.transform(self.qs))[::k.step] or self.transform(self.qs)
File "/usr/local/lib/python3.4/site-packages/sequere/contrib/timeline/query.py", line 38, in transform
return self._transform(scores)
File "/usr/local/lib/python3.4/site-packages/sequere/contrib/timeline/query.py", line 51, in _transform
for data in pipe.execute()]
File "/usr/local/lib/python3.4/site-packages/sequere/contrib/timeline/query.py", line 51, in <listcomp>
for data in pipe.execute()]
File "/usr/local/lib/python3.4/site-packages/sequere/contrib/timeline/action.py", line 86, in from_data
verb = data['verb']
KeyError: 'verb'
In my use case the user would select between showing events of people they are following, their own, or everyone. The first two I think match sequere's public and private timelines. There is not currently a way to get all events, outside of directly querying redis, right? Is a feature like this inline with what you want django-sequere to be?
I'm not sure what's going on here. Is the Timeline only available with redis? Even so I have redis working but am having trouble.
worker_1 | [2015-03-17 22:49:36,881: ERROR/MainProcess] Task sequere.contrib.timeline.tasks.import_actions[0c7da3c2-1b75-4fcd-92d5-056aaaa59d15] raised unexpected: KeyError('identifier',)
worker_1 | Traceback (most recent call last):
worker_1 | File "/usr/local/lib/python3.4/site-packages/celery/app/trace.py", line 240, in trace_task
worker_1 | R = retval = fun(*args, **kwargs)
worker_1 | File "/usr/local/lib/python3.4/site-packages/celery/app/trace.py", line 438, in __protected_call__
worker_1 | return self.run(*args, **kwargs)
worker_1 | File "/usr/local/lib/python3.4/site-packages/sequere/contrib/timeline/tasks.py", line 68, in import_actions
worker_1 | logger=import_actions.get_logger())
worker_1 | File "/usr/local/lib/python3.4/site-packages/sequere/contrib/timeline/tasks.py", line 44, in populate_actions
worker_1 | from_instance = manager.get_from_uid(from_uid)
worker_1 | File "/usr/local/lib/python3.4/site-packages/sequere/backends/redis/managers.py", line 81, in get_from_uid
worker_1 | klass = registry.identifiers.get(data['identifier'])
worker_1 | KeyError: 'identifier'
You are a liar and I'm pinging you :)
Working on a pull request, fixed a couple obvious issues. https://github.com/bufke/django-sequere. This may not be python 3 related though.
Python 3.4.2 (default, Jan 1 2015, 13:14:17)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from core.models import *
>>> p1 = Profile.objects.all()[0]
>>> p2 = Profile.objects.all()[1]
>>> p1.follow(p2)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.4/site-packages/sequere/mixin.py", line 5, in follow
return follow(self, instance)
File "/usr/local/lib/python3.4/site-packages/sequere/models.py", line 7, in follow
return get_backend()().follow(from_instance, to_instance)
File "/usr/local/lib/python3.4/site-packages/sequere/backends/database/__init__.py", line 44, in follow
to_instance=to_instance))
File "/usr/local/lib/python3.4/site-packages/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/db/models/query.py", line 424, in get_or_create
return self._create_object_from_params(lookup, params)
File "/usr/local/lib/python3.4/site-packages/django/db/models/query.py", line 465, in _create_object_from_params
six.reraise(*exc_info)
File "/usr/local/lib/python3.4/site-packages/django/utils/six.py", line 659, in reraise
raise value
File "/usr/local/lib/python3.4/site-packages/django/db/models/query.py", line 457, in _create_object_from_params
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 589, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 617, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 698, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 731, in _do_insert
using=using, raw=raw)
File "/usr/local/lib/python3.4/site-packages/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/db/models/query.py", line 921, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 920, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: null value in column "from_identifier" violates not-null constraint
DETAIL: Failing row contains (1, 2015-03-17 17:42:36.307382+00, 1, null, 2, null, f).
When django.contrib.admin.apps.SimpleAdminConfig is configured in INSTALLED_APPS, it results in this exception:
Traceback (most recent call last):
File "/spv/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/virtual_envs/spv_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/virtual_envs/spv_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/virtual_envs/spv_env/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/virtual_envs/spv_env/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/virtual_envs/spv_env/local/lib/python2.7/site-packages/sequere/apps.py", line 10, in ready
self.module.autodiscover()
File "/virtual_envs/spv_env/local/lib/python2.7/site-packages/sequere/registry.py", line 117, in autodiscover
_autodiscover(registry)
File "/virtual_envs/spv_env/local/lib/python2.7/site-packages/sequere/registry.py", line 95, in _autodiscover
mod = import_module(app)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named SimpleAdminConfig
This is caused by sequere _autodiscover trying to load module from INSTALLED_APPS
def _autodiscover(registry):
import copy
from django.conf import settings
from django.utils.module_loading import module_has_submodule
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module # noqa
for app in settings.INSTALLED_APPS:
mod = import_module(app)
This will fail when dotted AppConfig path used in INSTALLED_APPS.
Django Admin autodiscover uses apps.get_app_configs() instead:
for app_config in apps.get_app_configs():
I will try to fix and hopefully a PR will follow..
When using the database provider to store follows, you can't use timeline at the moment.
ping @bufke
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.