adaptive-learning / proso-apps

Django modules for an adaptive practice system (currently used by http://slepemapy.cz/ or https://anatom.cz/)
MIT License
2 stars 7 forks source link

/models/to_practice fails on staging.anatom.cz #167

Closed slaweet closed 8 years ago

slaweet commented 8 years ago

https://staging.anatom.cz/models/to_practice/?html=True

KeyError at /models/to_practice/
2580
Request Method: GET
Request URL:    http://staging.anatom.cz/models/to_practice/?html=True
Django Version: 1.9.1
Exception Type: KeyError
Exception Value:    
2580
Exception Location: /usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso_models/models.py in <lambda>, line 796
Python Executable:  /usr/local/share/.virtualenvs/anatomy3-staging/bin/python3.5
Python Version: 3.5.0
Python Path:    
['/var/www/webs/anatomy-staging/source',
 '/usr/local/share/.virtualenvs/anatomy3-staging/bin',
 '/usr/local/share/.virtualenvs/anatomy3-staging/lib/python35.zip',
 '/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5',
 '/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/plat-linux',
 '/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/lib-dynload',
 '/usr/local/lib/python3.5',
 '/usr/local/lib/python3.5/plat-linux',
 '/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages']
Server time:    pá, 1 Čec 2016 12:22:45 +0000
Traceback Switch to copy-and-paste view

/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/django/core/handlers/base.py in get_response
                    response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/django/core/handlers/base.py in get_response
                    response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso/django/cache.py in __cache_page_conditional
            return f(request, *args, **kwargs) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/django/utils/decorators.py in _wrapped_view
                    response = view_func(request, *args, **kwargs) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso_models/views.py in to_practice
    return render_json(request, result, template='models_json.html', help_text=to_practice.__doc__) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso/django/response.py in render_json
    json = enrich_json_objects_by_object_type(request, json) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso/django/enrichment.py in enrich_json_objects_by_object_type
            enricher_info['enricher'](request, enricher_objects, enricher_nested) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso/django/enrichment.py in enricher_fun
            return _enricher_fun(enricher)(request, json_list, nested) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso_models/json_enrich.py in item2object
    translated = models.Item.objects.translate_item_ids(item_ids, get_language(request), is_nested=nested) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso_models/models.py in translate_item_ids
        groupped = proso.list.group_by(item_ids, by=lambda item_id: all_item_type_ids[item_id]) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso/list.py in group_by
    return proso.dict.group_keys_by_values({x: by(x) for x in what}) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso/list.py in <dictcomp>
    return proso.dict.group_keys_by_values({x: by(x) for x in what}) ...
▶ Local vars
/usr/local/share/.virtualenvs/anatomy3-staging/lib/python3.5/site-packages/proso_models/models.py in <lambda>
        groupped = proso.list.group_by(item_ids, by=lambda item_id: all_item_type_ids[item_id]) ...
▶ Local vars
Request information

GET
Variable    Value
html    
'True'
POST
No POST data
FILES
No FILES data
COOKIES
Variable    Value
_ga 
'GA1.2.1557488137.1460528494'
__insp_slim 
'1467299355491'
configService%3Aoverridden  
'%7B%22debug%22%3Atrue%7D'
__insp_targlpu  
'https%3A%2F%2Fanatom.cz%2F'
offer   
'true'
toolbar%3Amaximized 
'false'
__insp_nv   
'true'
__insp_norec_sess   
'true'
termsLang   
'cs'
__insp_targlpt  
'Anatom.cz%20-%20procvi%C4%8Dov%C3%A1n%C3%AD%20anatomie%20%C4%8Dlov%C4%9Bka%20v%20obr%C3%A1zc%C3%ADch'
practiceDropdownUsed    
'true'
toolbar%3Aopened    
'false'
__insp_ref  
'd'
sessionid   
'fntv3bimdzg62dl34k2v1lgrn1tbvqn6'
__insp_wid  
'1923823504'
csrftoken   
'IbVdBGn2PliMQ5jLMG7fF6oTdKCE7kdd'
META
Variable    Value
REMOTE_ADDR 
"b''"
SERVER_NAME 
'staging.anatom.cz'
wsgi.version    
(1, 0)
HTTP_REFERER    
'https://staging.anatom.cz/models/'
SERVER_PROTOCOL 
'HTTP/1.0'
wsgi.run_once   
False
HTTP_UPGRADE_INSECURE_REQUESTS  
'1'
RAW_URI 
'/models/to_practice/?html=True'
wsgi.file_wrapper   
''
HTTP_X_FORWARDED_FOR    
'147.251.52.11'
QUERY_STRING    
'html=True'
HTTP_ACCEPT_LANGUAGE    
'en'
HTTP_ACCEPT 
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
wsgi.multiprocess   
False
wsgi.errors 
<gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f74acaecb00>
wsgi.url_scheme 
'http'
wsgi.input  
<gunicorn.http.body.Body object at 0x7f74acaec518>
SERVER_PORT 
'80'
wsgi.multithread    
True
HTTP_COOKIE 
('termsLang=cs; __insp_wid=1923823504; __insp_nv=true; __insp_ref=d; '
 '__insp_targlpu=https%3A%2F%2Fanatom.cz%2F; '
 '__insp_targlpt=Anatom.cz%20-%20procvi%C4%8Dov%C3%A1n%C3%AD%20anatomie%20%C4%8Dlov%C4%9Bka%20v%20obr%C3%A1zc%C3%ADch; '
 '__insp_norec_sess=true; _ga=GA1.2.1557488137.1460528494; '
 '__insp_slim=1467299355491; offer=true; practiceDropdownUsed=true; '
 'configService%3Aoverridden=%7B%22debug%22%3Atrue%7D; toolbar%3Aopened=false; '
 'toolbar%3Amaximized=false; sessionid=fntv3bimdzg62dl34k2v1lgrn1tbvqn6; '
 'csrftoken=IbVdBGn2PliMQ5jLMG7fF6oTdKCE7kdd')
HTTP_HOST   
'staging.anatom.cz'
SERVER_SOFTWARE 
'gunicorn/19.4.5'
REQUEST_METHOD  
'GET'
PATH_INFO   
'/models/to_practice/'
HTTP_USER_AGENT 
('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) '
 'Chrome/51.0.2704.106 Safari/537.36')
HTTP_ACCEPT_ENCODING    
'gzip, deflate, sdch, br'
CSRF_COOKIE 
'IbVdBGn2PliMQ5jLMG7fF6oTdKCE7kdd'
SCRIPT_NAME 
''
gunicorn.socket 
<socket.socket fd=12, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, laddr=/var/www/webs/anatomy-staging/gunicorn.sock>
HTTP_CONNECTION 
'close'
Settings
Using settings module anatomy.settings
Setting Value
SESSION_FILE_PATH   
None
HASHES  
{}
AUTH_USER_MODEL 
'auth.User'
STATICFILES_DIRS    
('/var/www/webs/anatomy-staging/source/anatomy/static',)
SESSION_COOKIE_SECURE   
False
FIXTURE_DIRS    
[]
SESSION_EXPIRE_AT_BROWSER_CLOSE 
False
BASE_DIR    
'/var/www/webs/anatomy-staging/source'
DATA_DIR    
'/var/www/webs/anatomy-staging/source/data'
SECRET_KEY  
'********************'
SERVER_EMAIL    
'root@localhost'
ON_PRODUCTION   
False
USE_I18N    
True
ROOT_URLCONF    
'anatomy.urls'
LANGUAGE_COOKIE_PATH    
'/'
SOCIAL_AUTH_FACEBOOK_SECRET 
'********************'
USE_X_FORWARDED_PORT    
False
FILEBROWSER_DIRECTORY   
'thumbs/'
MEDIA_URL   
'/media/'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET    
'********************'
MONTH_DAY_FORMAT    
'F j'
CACHES  
{'default': {'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
             'LOCATION': '/var/www/webs/anatomy-staging/source/data/.django_cache',
             'OPTIONS': {'MAX_ENTRIES': 30000},
             'TIMEOUT': 604800}}
CSRF_HEADER_NAME    
'HTTP_X_CSRFTOKEN'
SILENCED_SYSTEM_CHECKS  
[]
SECURE_HSTS_INCLUDE_SUBDOMAINS  
False
SECURE_CONTENT_TYPE_NOSNIFF 
False
ALLOWED_HOSTS   
['anatom.cz', 'practiceanatomy.com']
PASSWORD_RESET_TIMEOUT_DAYS 
'********************'
TIME_INPUT_FORMATS  
['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
DATETIME_FORMAT 
'N j, Y, P'
TEST_NON_SERIALIZED_APPS    
[]
EMAIL_HOST_PASSWORD 
'********************'
EMAIL_PORT  
25
TEMPLATE_CONTEXT_PROCESSORS 
['django.contrib.auth.context_processors.auth',
 'django.template.context_processors.debug',
 'django.template.context_processors.i18n',
 'django.template.context_processors.media',
 'django.template.context_processors.static',
 'django.template.context_processors.tz',
 'django.contrib.messages.context_processors.messages',
 'proso_common.context_processors.config_processor']
LANGUAGE_COOKIE_DOMAIN  
None
STATICFILES_STORAGE 
'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
SECURE_BROWSER_XSS_FILTER   
False
SECURE_SSL_HOST 
None
DISALLOWED_USER_AGENTS  
[]
LOGOUT_URL  
'/accounts/logout/'
SOCIAL_AUTH_RAISE_EXCEPTIONS    
False
SESSION_COOKIE_AGE  
1209600
DATABASE_ROUTERS    
[]
CSRF_TRUSTED_ORIGINS    
[]
SECURE_SSL_REDIRECT 
False
CSRF_COOKIE_SECURE  
False
LOGGING 
{'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'}},
 'formatters': {'simple': {'format': '[%(asctime)s] %(levelname)s '
                                     '"%(message)s"'}},
 'handlers': {'anatomy_file': {'class': 'logging.FileHandler',
                               'filename': '/var/www/webs/anatomy-staging/source/data/anatomy.log',
                               'formatter': 'simple',
                               'level': 'INFO'},
              'console': {'class': 'logging.StreamHandler',
                          'filters': [],
                          'formatter': 'simple',
                          'level': 'DEBUG'},
              'mail_admins': {'class': 'django.utils.log.AdminEmailHandler',
                              'filters': ['require_debug_false'],
                              'level': 'ERROR'},
              'mail_admins_javascript': {'class': 'proso.django.log.AdminJavascriptEmailHandler',
                                         'filters': ['require_debug_false'],
                                         'level': 'ERROR'},
              'request': {'class': 'proso.django.log.RequestHandler',
                          'formatter': 'simple',
                          'level': 'DEBUG'}},
 'loggers': {'django.request': {'handlers': ['console',
                                             'request',
                                             'mail_admins',
                                             'anatomy_file'],
                                'level': 'DEBUG',
                                'propagate': True},
             'javascript': {'handlers': ['console',
                                         'mail_admins_javascript',
                                         'anatomy_file'],
                            'level': 'INFO',
                            'propagate': True}},
 'version': 1}
SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH   
135
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY   
'********************'
USE_THOUSAND_SEPARATOR  
False
SOCIAL_AUTH_FACEBOOK_EXTENDED_PERMISSIONS   
['email']
USE_TZ  
True
LOGIN_ERROR_URL 
'/login/error/'
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH   
125
SESSION_ENGINE  
'django.contrib.sessions.backends.db'
FIRST_DAY_OF_WEEK   
0
LANGUAGE_COOKIE_NAME    
'django_language'
SHORT_DATE_FORMAT   
'm/d/Y'
ABSOLUTE_URL_OVERRIDES  
{}
NUMBER_GROUPING 
0
LOCALE_PATHS    
('/var/www/webs/anatomy-staging/source/conf/locale',)
IGNORABLE_404_URLS  
[]
CACHE_MIDDLEWARE_ALIAS  
'default'
MEDIA_ROOT  
'/var/www/webs/anatomy-staging/source/../media'
FILE_UPLOAD_HANDLERS    
['django.core.files.uploadhandler.MemoryFileUploadHandler',
 'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FORCE_SCRIPT_NAME   
None
TEMPLATE_DIRS   
('/var/www/webs/anatomy-staging/source/anatomy/templates',)
MESSAGE_STORAGE 
'django.contrib.messages.storage.fallback.FallbackStorage'
DATABASES   
{'default': {'ATOMIC_REQUESTS': False,
             'AUTOCOMMIT': True,
             'CONN_MAX_AGE': 0,
             'ENGINE': 'django.db.backends.postgresql_psycopg2',
             'HOST': 'localhost',
             'NAME': 'anatomy-staging',
             'OPTIONS': {},
             'PASSWORD': '********************',
             'PORT': '',
             'TEST': {'CHARSET': None,
                      'COLLATION': None,
                      'MIRROR': None,
                      'NAME': None},
             'TIME_ZONE': None,
             'USER': 'anatomy-staging'}}
SOCIAL_AUTH_FORCE_RANDOM_USERNAME   
False
SECURE_PROXY_SSL_HEADER 
None
FORMAT_MODULE_PATH  
None
YEAR_MONTH_FORMAT   
'F Y'
TEMPLATE_DEBUG  
True
MANAGERS    
[]
DEFAULT_CONTENT_TYPE    
'text/html'
PROSO_FLASHCARDS    
{}
AUTH_DOMAIN 
'staging.anatom.cz'
TEMPLATE_LOADERS    
['django.template.loaders.filesystem.Loader',
 'django.template.loaders.app_directories.Loader']
EMAIL_SSL_KEYFILE   
'********************'
FILE_CHARSET    
'utf-8'
DEBUG   
True
SESSION_CACHE_ALIAS 
'default'
SESSION_COOKIE_NAME 
'sessionid'
SESSION_COOKIE_DOMAIN   
None
EMAIL_SSL_CERTFILE  
None
CSRF_COOKIE_NAME    
'csrftoken'
INTERNAL_IPS    
['::1', '127.0.0.1']
PROSO_JS_FILES  
['dist/js/bower-libs.js', 'dist/js/proso-apps-all.js']
LANGUAGES_BIDI  
['he', 'ar', 'fa', 'ur']
SECURE_REDIRECT_EXEMPT  
[]
DATE_FORMAT 
'N j, Y'
LANGUAGE_DOMAINS    
{'cs': 'staging.anatom.cz', 'en': 'staging.practiceanatomy.com'}
EMAIL_HOST_USER 
''
EMAIL_BACKEND   
'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL  
'webmaster@localhost'
APPEND_SLASH    
True
SHORT_DATETIME_FORMAT   
'm/d/Y P'
STATIC_URL  
'/static/'
DATETIME_INPUT_FORMATS  
['%Y-%m-%d %H:%M:%S',
 '%Y-%m-%d %H:%M:%S.%f',
 '%Y-%m-%d %H:%M',
 '%Y-%m-%d',
 '%m/%d/%Y %H:%M:%S',
 '%m/%d/%Y %H:%M:%S.%f',
 '%m/%d/%Y %H:%M',
 '%m/%d/%Y',
 '%m/%d/%y %H:%M:%S',
 '%m/%d/%y %H:%M:%S.%f',
 '%m/%d/%y %H:%M',
 '%m/%d/%y']
LOGGING_CONFIG  
'logging.config.dictConfig'
SOCIAL_AUTH_FACEBOOK_KEY    
'********************'
DEFAULT_TABLESPACE  
''
SESSION_SAVE_EVERY_REQUEST  
False
SESSION_SERIALIZER  
'django.contrib.sessions.serializers.PickleSerializer'
SESSION_COOKIE_PATH 
'/'
ON_STAGING  
True
DEFAULT_EXCEPTION_REPORTER_FILTER   
'django.views.debug.SafeExceptionReporterFilter'
PROSO_CONFIG    
{'path': '/var/www/webs/anatomy-staging/source/anatomy/proso_config.yaml'}
TEST_RUNNER 
'django.test.runner.DiscoverRunner'
WSGI_APPLICATION    
'anatomy.wsgi.application'
ADMINS  
(('Vít Stanislav', 'slaweet@gmail.com'),)
SOCIAL_AUTH_UID_LENGTH  
222
TIME_ZONE   
'UTC'
LANGUAGES   
(('cs', 'Česky'), ('en', 'English'))
LOGIN_REDIRECT_URL  
'/'
STATIC_ROOT 
'/var/www/webs/anatomy-staging/source/../static'
DECIMAL_SEPARATOR   
'.'
X_FRAME_OPTIONS 
'SAMEORIGIN'
FILE_UPLOAD_PERMISSIONS 
None
AUTHENTICATION_BACKENDS 
('django.contrib.auth.backends.ModelBackend',
 'lazysignup.backends.LazySignupBackend',
 'social.backends.facebook.FacebookOAuth2',
 'social.backends.google.GoogleOAuth2')
SECURE_HSTS_SECONDS 
0
CACHE_MIDDLEWARE_KEY_PREFIX 
'********************'
EMAIL_USE_SSL   
False
EMAIL_TIMEOUT   
None
TEMPLATE_STRING_IF_INVALID  
''
SOCIAL_AUTH_DEFAULT_USERNAME    
'new_social_auth_user'
DEFAULT_INDEX_TABLESPACE    
''
FILE_UPLOAD_MAX_MEMORY_SIZE 
2621440
CSRF_COOKIE_PATH    
'/'
FILE_UPLOAD_TEMP_DIR    
None
PREPEND_WWW 
False
PASSWORD_HASHERS    
'********************'
ALLOWED_INCLUDE_ROOTS   
[]
CSRF_COOKIE_HTTPONLY    
False
DATE_INPUT_FORMATS  
['%Y-%m-%d',
 '%m/%d/%Y',
 '%m/%d/%y',
 '%b %d %Y',
 '%b %d, %Y',
 '%d %b %Y',
 '%d %b, %Y',
 '%B %d %Y',
 '%B %d, %Y',
 '%d %B %Y',
 '%d %B, %Y']
TIME_FORMAT 
'P'
LOGIN_URL   
'/accounts/login/'
MIGRATION_MODULES   
{}
DEFAULT_FILE_STORAGE    
'django.core.files.storage.FileSystemStorage'
SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH 
200
EMAIL_SUBJECT_PREFIX    
'[anatom.cz] '
SESSION_COOKIE_HTTPONLY 
True
USE_ETAGS   
False
LANGUAGE_CODE   
'cs'
CSRF_COOKIE_DOMAIN  
None
SOCIAL_AUTH_SESSION_EXPIRATION  
False
SOCIAL_AUTH_CREATE_USERS    
True
DEFAULT_CHARSET 
'utf-8'
CSRF_FAILURE_VIEW   
'django.views.csrf.csrf_failure'
SOCIAL_AUTH_ERROR_KEY   
'********************'
INSTALLED_APPS  
('debug_toolbar',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'flatblocks',
 'lazysignup',
 'proso_ab',
 'proso_configab',
 'proso_common',
 'proso_models',
 'proso_user',
 'proso_feedback',
 'proso_flashcards',
 'social.apps.django_app.default',
 'grappelli',
 'filebrowser',
 'anatomy')
LANGUAGE_COOKIE_AGE 
None
EMAIL_USE_TLS   
False
SETTINGS_MODULE 
'anatomy.settings'
USE_X_FORWARDED_HOST    
False
THOUSAND_SEPARATOR  
','
DEBUG_PROPAGATE_EXCEPTIONS  
False
CACHE_MIDDLEWARE_SECONDS    
600
STATICFILES_FINDERS 
('django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder')
EMAIL_HOST  
'localhost'
MIDDLEWARE_CLASSES  
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'proso_common.middleware.ToolbarMiddleware',
 'proso.django.request.RequestMiddleware',
 'proso_ab.models.ABMiddleware',
 'proso.django.cache.RequestCacheMiddleware',
 'proso.django.log.RequestLogMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'anatomy.middleware.LanguageInDomainMiddleware',
 'anatomy.middleware.GoogleAuthChangeDomain',
 'proso_common.middleware.AuthAlreadyAssociatedMiddleware')
USE_L10N    
True
AUTH_PASSWORD_VALIDATORS    
'********************'
SIGNING_BACKEND 
'django.core.signing.TimestampSigner'
FILE_UPLOAD_DIRECTORY_PERMISSIONS   
None
TEMPLATES   
[]
CSRF_COOKIE_AGE 
31449600
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.
papousek commented 8 years ago

Interesting. Item 2580 is not referenced by any object (like Term, Context, Category or Flashcard). I have deleted it from database.

How has it happened?