Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

講演者プロフィール表示が502になる #120

Open
miurahr opened this issue Oct 17, 2015 · 6 comments
Open

講演者プロフィール表示が502になる #120

miurahr opened this issue Oct 17, 2015 · 6 comments

Comments

@miurahr
Copy link
Member

miurahr commented Oct 17, 2015

http://staging.stateofthemap.jp/2015/speaker/profile/1/

502 Bad Gateway

nginx/1.4.6 (Ubuntu)
@miurahr
Copy link
Member Author

miurahr commented Oct 17, 2015

[2015-10-17 09:30:15 +0000] [7581] [ERROR] Socket error processing request.
Traceback (most recent call last):
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle
    self.handle_request(listener, req, client, addr)
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 187, in handle_request
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
    response = self.get_response(request)
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 199, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 231, in handle_uncaught_exception
    'request': request
  File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1271, in _log
    self.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1281, in handle
    self.callHandlers(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1321, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 749, in handle
    self.emit(record)
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/utils/log.py", line 132, in emit
    connection=self.connection())
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 98, in mail_admins
    mail.send(fail_silently=fail_silently)
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/mail/message.py", line 286, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 92, in send_messages
    new_conn_created = self.open()
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 50, in open
    self.connection = connection_class(self.host, self.port, **connection_params)
  File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 316, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
error: [Errno 111] Connection refused

@miurahr
Copy link
Member Author

miurahr commented Oct 17, 2015

これは、sotmjp/settings/server.pyでmail_adminハンドラーが設定されているが、メールが出せないためにエラーになっている。環境Issue

diff --git a/sotmjp/settings/server.py b/sotmjp/settings/server.py
index 215142a..35affae 100644
--- a/sotmjp/settings/server.py
+++ b/sotmjp/settings/server.py
@@ -106,18 +106,16 @@ LOGGING['loggers'].update({
         'level': env_or_default('LOG_LEVEL', 'INFO'),
     },
     'django.request': {
-        'handlers': ['mail_admins', 'sotmjp_error_log'],
+        'handlers': ['sotmjp_error_log'],
         'level': 'ERROR',
         'propagate': True,
     },
     'sotmjp': {
-        # mail_admins will only accept ERROR and higher
-        'handlers': ['mail_admins', 'sotmjp_error_log'],
+        'handlers': ['sotmjp_error_log'],
         'level': 'WARNING',
     },
     'symposion': {
-        # mail_admins will only accept ERROR and higher
-        'handlers': ['mail_admins', 'sotmjp_error_log'],
+        'handlers': ['sotmjp_error_log'],
         'level': 'WARNING',
     }
 })

@miurahr
Copy link
Member Author

miurahr commented Oct 17, 2015

mail_adminハンドラーを削除すると

SotM JP 2014

Oops, we've had a problem on the server. The web team have been informed and will be looking into it but if you have any questions, don't hesitate to email:

[email protected]

となる

@miurahr
Copy link
Member Author

miurahr commented Oct 17, 2015

ubuntu@ip-172-30-1-252:/var/log/sotmjp⟫ tail -f sotmjp_website.error.log 
AttributeError: 'Speaker' object has no attribute 'presentations'
[2015-10-17 09:36:16][django.request] ERROR Internal Server Error: /2015/speaker/profile/1/
Traceback (most recent call last):
  File "/srv/sites/sotmjp-website/env/sotmjp-website/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/srv/sites/sotmjp-website/env/sotmjp-website/src/symposion/symposion/speakers/views.py", line 131, in speaker_profile
    presentations = speaker.all_presentations
  File "/srv/sites/sotmjp-website/env/sotmjp-website/src/symposion/symposion/speakers/models.py", line 70, in all_presentations
    if self.presentations:
AttributeError: 'Speaker' object has no attribute 'presentations'

@miurahr
Copy link
Member Author

miurahr commented Oct 17, 2015

./manage.py shell
>>> from symposion.speakers.models import *
>>> from symposion.schedule.models import *
>>> from sotmjp.proposals.models import *
>>> s1 = Speaker(pk=8)
>>> s2 = Speaker(pk=1)
>>> Proposal_base.objects.filter(speaker=s2)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
NameError: name 'Proposal_base' is not defined
>>> TalkProposal.objects.filter(speaker=s2)
[]
>>> TalkProposal.objects.filter(speaker=s1)
[<TalkProposal: 題目その2 - ikiya(講演)>, <TalkProposal: The State of Fukushima  - ikiya(講演)>]
>>> TalkProposal.objects.filter(additional_speakers=s2)
[<TalkProposal: 題目その2 - ikiya(講演)>]

@miurahr
Copy link
Member Author

miurahr commented Oct 17, 2015

オリジナルでは、Speakerオブジェクトから、講演者の講演を引き出すためには、ManyToManyフィールドとしてPresentationに定義されているspeakerフィールドを利用して、逆参照をspeakerから行えばよかった。

ProposalとPresentationがリンクするようにしたことにより、Presentationにspeakerフィールドがなくなり、 TalkProposalのspeakerフィールドを参照しないとPresentationのspeakerをキーにPresentationを引けなくなったという問題である

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant