kapilratnani / django_hana

[Discontinued] Django db backend for SAP HANA
BSD 3-Clause "New" or "Revised" License
20 stars 13 forks source link

Save Error #2

Closed george-quaye-sap-com closed 11 years ago

george-quaye-sap-com commented 11 years ago

"Attempting to post a new question and encountered this error... the info did get posted to the table"

Environment: Request Method: GET Request URL: http://10.48.171.221:8000/question/1/first-question

Django Version: 1.4.2 Python Version: 2.7.3 Installed Applications: ('django_extensions', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'grappelli', 'django.contrib.admin', 'haystack', 'webapp') Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')

Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/home/lroot/sap_hana_answers_server/server/webapp/decorators.py" in _decorated
  2. return the_func(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  3. response = view_func(request, _args, *_kwargs) File "/home/lroot/sap_hana_answers_server/server/webapp/views.py" in call
  4. return self.read(request, id) File "/home/lroot/sap_hana_answers_server/server/webapp/views.py" in read
  5. for q in rel_questions: File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iter
  6. query = iter(self.query) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in iter
  7. self._execute_query() File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in _execute_query
  8. self.cursor.execute(self.sql, self.params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/hana/base.py" in execute
  9. return CursorWrapper.execute(self,sql, params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/hana/base.py" in execute
  10. self.cursor.execute(self._replace_params(sql,len(params) if params else 0),params) File "/usr/local/lib/python2.7/dist-packages/hdbcli/dbapi.py" in execute
  11. ret = self.execute(operation, tuple(parameters)) File "/usr/local/lib/python2.7/dist-packages/hdbcli/dbapi.py" in execute
  12. ret = self.__cursor.execute(operation, parameters=parameters, iscall=iscall)

Exception Type: Error at /question/1/first-question Exception Value: (257, 'sql syntax error: incorrect syntax near ",": line 12 col 15 (at pos 457)')

kapilratnani commented 11 years ago

With the above trace it is hard to understand what went wrong. It doesn't even have line numbers. Kindly set DEBUG=True in the settings.py and use the below logging configurations. This will print the exact queries that were sent for execution and will help me track the problem faster.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },'django.db.backends': {
            'level': 'DEBUG',
            'handers': ['console'],
        },
    }
}
george-quaye-sap-com commented 11 years ago

The error page is complex... and not easily attahced or shown in cut and paste... so, I got the page source and pasting the entire html...

<!DOCTYPE html>

Error at /question/1141/this-is-a-test-of-adding-a-question234

Error at /question/1141/this-is-a-test-of-adding-a-question234

(257, 'sql syntax error: incorrect syntax near ",": line 12 col 15 (at pos 457)')
Request Method: GET
Request URL: http://10.48.171.221:8000/question/1141/this-is-a-test-of-adding-a-question234
Django Version: 1.4.2
Exception Type: Error
Exception Value:
(257, 'sql syntax error: incorrect syntax near ",": line 12 col 15 (at pos 457)')
Exception Location: /usr/local/lib/python2.7/dist-packages/hdbcli/dbapi.py in __execute, line 244
Python Executable: /usr/local/bin/python
Python Version: 2.7.3
Python Path:
['/home/lroot/sap_hana_answers_server/server',
 '/home/lroot/sap_hana_answers_server/server/src/pysaml2/src',
 '/usr/local/lib/python2.7/dist-packages/distribute-0.6.35-py2.7.egg',
 '/home/lroot/sap_hana_answers_server/server/src/django-haystack',
 '/home/lroot/sap_hana_answers_server/server',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/local/lib/python27.zip',
 '/usr/local/lib/python2.7',
 '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk',
 '/usr/local/lib/python2.7/lib-old',
 '/usr/local/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/site-packages',
 '/home/ubuntu/sap-hana-error/server']
Server time: Fri, 29 Mar 2013 20:50:08 +0100

Traceback Switch to copy-and-paste view

  • /usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response
    1.                     for middleware_method in self._view_middleware:
    2.                         response = middleware_method(request, callback, callback_args, callback_kwargs)
    3.                         if response:
    4.                             break
    5.                 if response is None:
    6.                     try:
    1.                         response = callback(request, *callback_args, **callback_kwargs)
      ...
    1.                     except Exception, e:
    2.                         # If the view raised an exception, run it through exception
    3.                         # middleware, and if the exception middleware returns a
    4.                         # response, use that. Otherwise, reraise the exception.
    5.                         for middleware_method in self._exception_middleware:
    6.                             response = middleware_method(request, e)
    ```
    Variable Value
    exceptions
    <module 'django.core.exceptions' from '/usr/local/lib/python2.7/dist-packages/django/core/exceptions.pyc'>
    e
    Error(257, 'sql syntax error: incorrect syntax near ",": line 12 col 15 (at pos 457)')
    callback_args
    ()
    settings
    <django.conf.LazySettings object at 0x18551d0>
    middleware_method
    <bound method MessageMiddleware.process_request of <django.contrib.messages.middleware.MessageMiddleware object at 0x7fefb4005690>>
    self
    <django.core.handlers.wsgi.WSGIHandler object at 0x236d150>
    request
    "<WSGIRequest\npath:/question/1141/this-is-a-test-of-adding-a-question234,\nGET:<QueryDict: {}>,\nPOST:<QueryDict: {}>,\nCOOKIES:{'csrftoken': 'PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ',\n 'sessionid': 'e939f0325dd83398e572dbf63aa48581'},\nMETA:{'CONTENT_LENGTH': '',\n 'CONTENT_TYPE': 'text/plain',\n 'DJANGO_SETTINGS_MODULE': 'server.settings',\n 'GATEWAY_INTERFACE': 'CGI/1.1',\n 'HOME': '/home/lroot',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',\n 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',\n 'HTTP_CACHE_CONTROL': 'max-age=0',\n 'HTTP_CONNECTION': 'keep-alive',\n 'HTTP_COOKIE': 'csrftoken=PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ; sessionid=e939f0325dd83398e572dbf63aa48581',\n 'HTTP_HOST': '10.48.171.221:8000',\n 'HTTP_REFERER': 'http://10.48.171.221:8000/ask',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22',\n 'LANG': 'en_US.UTF-8',\n 'LESSCLOSE': '/usr/bin/lesspipe %s %s',\n 'LESSOPEN': '| /usr/bin/lesspipe %s',\n 'LOGNAME': 'lroot',\n 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:',\n 'MAIL': '/var/mail/lroot',\n 'OLDPWD': '/home/lroot',\n 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',\n 'PATH_INFO': u'/question/1141/this-is-a-test-of-adding-a-question234',\n 'PWD': '/home/lroot/sap_hana_answers_server/server',\n 'PYTHONPATH': ':/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '10.48.241.43',\n 'REMOTE_HOST': '',\n 'REQUEST_METHOD': 'GET',\n 'RUN_MAIN': 'true',\n 'SCRIPT_NAME': u'',\n 'SERVER_NAME': 'george.pal.sap.corp',\n 'SERVER_PORT': '8000',\n 'SERVER_PROTOCOL': 'HTTP/1.1',\n 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.3rc1',\n 'SHELL': '/bin/bash',\n 'SHLVL': '1',\n 'SSH_CLIENT': '10.48.241.43 64953 22',\n 'SSH_CONNECTION': '10.48.241.43 64953 10.48.171.221 22',\n 'SSH_TTY': '/dev/pts/0',\n 'TERM': 'xterm',\n 'TZ': 'Europe/Berlin',\n 'USER': 'lroot',\n 'XDG_SESSION_COOKIE': '13ff287091c3db8e81d4af57000001e8-1364584454.735821-20045594',\n '_': '/usr/local/bin/python',\n 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fefd8385270>,\n 'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x1db6bb0>,\n 'wsgi.input': <socket._fileobject object at 0x7fefc804b3d0>,\n 'wsgi.multiprocess': False,\n 'wsgi.multithread': True,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>"
    callback
    <webapp.views.QuestionResource object at 0x7fefc00630d0>
    resolver
    <RegexURLResolver server.urls (None:None) ^/>
    urlresolvers
    <module 'django.core.urlresolvers' from '/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.pyc'>
    callback_kwargs
    {'id': u'1141', 'slug': u'this-is-a-test-of-adding-a-question234'}
    response
    None
    urlconf
    'server.urls'
  • /home/lroot/sap_hana_answers_server/server/webapp/decorators.py in _decorated
    1.     """
    2.     def _decorated(*args, **kwargs):
    3.      request = args[0] if isinstance(args[0], WSGIRequest) else args[1] 
    4.        if (request.user and request.user.is_authenticated()\
    5.          and (request.user.username.startswith("I")\
    6.          or request.user.username.startswith("D")\
    7.            or request.user.username.startswith("C"))) or (request.user and request.user.is_staff):
    1.                return the_func(*args, **kwargs)
      ...
    1.         else:
    2.          return HttpResponseRedirect("/")
    3.     return _decorated
    ```
    Variable Value
    args
    (<webapp.views.QuestionResource object at 0x7fefc00630d0>,
    ```
    
     <WSGIRequest
    path:/question/1141/this-is-a-test-of-adding-a-question234,
    GET:<QueryDict: {}>,
    POST:<QueryDict: {}>,
    COOKIES:{'csrftoken': 'PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ',
     'sessionid': 'e939f0325dd83398e572dbf63aa48581'},
    META:{'CONTENT_LENGTH': '',
     'CONTENT_TYPE': 'text/plain',
     'DJANGO_SETTINGS_MODULE': 'server.settings',
     'GATEWAY_INTERFACE': 'CGI/1.1',
     'HOME': '/home/lroot',
     'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8',
     'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,_;q=0.3',
     'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
     'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
     'HTTP_CACHE_CONTROL': 'max-age=0',
     'HTTP_CONNECTION': 'keep-alive',
     'HTTP_COOKIE': 'csrftoken=PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ; sessionid=e939f0325dd83398e572dbf63aa48581',
     'HTTP_HOST': '10.48.171.221:8000',
     'HTTP_REFERER': 'http://10.48.171.221:8000/ask',
     'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22',
     'LANG': 'en_US.UTF-8',
     'LESSCLOSE': '/usr/bin/lesspipe %s %s',
     'LESSOPEN': '| /usr/bin/lesspipe %s',
     'LOGNAME': 'lroot',
     'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:_.tar=01;31:_.tgz=01;31:_.arj=01;31:_.taz=01;31:_.lzh=01;31:_.lzma=01;31:_.tlz=01;31:_.txz=01;31:_.zip=01;31:_.z=01;31:_.Z=01;31:_.dz=01;31:_.gz=01;31:_.lz=01;31:_.xz=01;31:_.bz2=01;31:_.bz=01;31:_.tbz=01;31:_.tbz2=01;31:_.tz=01;31:_.deb=01;31:_.rpm=01;31:_.jar=01;31:_.war=01;31:_.ear=01;31:_.sar=01;31:_.rar=01;31:_.ace=01;31:_.zoo=01;31:_.cpio=01;31:_.7z=01;31:_.rz=01;31:_.jpg=01;35:_.jpeg=01;35:_.gif=01;35:_.bmp=01;35:_.pbm=01;35:_.pgm=01;35:_.ppm=01;35:_.tga=01;35:_.xbm=01;35:_.xpm=01;35:_.tif=01;35:_.tiff=01;35:_.png=01;35:_.svg=01;35:_.svgz=01;35:_.mng=01;35:_.pcx=01;35:_.mov=01;35:_.mpg=01;35:_.mpeg=01;35:_.m2v=01;35:_.mkv=01;35:_.webm=01;35:_.ogm=01;35:_.mp4=01;35:_.m4v=01;35:_.mp4v=01;35:_.vob=01;35:_.qt=01;35:_.nuv=01;35:_.wmv=01;35:_.asf=01;35:_.rm=01;35:_.rmvb=01;35:_.flc=01;35:_.avi=01;35:_.fli=01;35:_.flv=01;35:_.gl=01;35:_.dl=01;35:_.xcf=01;35:_.xwd=01;35:_.yuv=01;35:_.cgm=01;35:_.emf=01;35:_.axv=01;35:_.anx=01;35:_.ogv=01;35:_.ogx=01;35:_.aac=00;36:_.au=00;36:_.flac=00;36:_.mid=00;36:_.midi=00;36:_.mka=00;36:_.mp3=00;36:_.mpc=00;36:_.ogg=00;36:_.ra=00;36:_.wav=00;36:_.axa=00;36:_.oga=00;36:_.spx=00;36:*.xspf=00;36:',
     'MAIL': '/var/mail/lroot',
     'OLDPWD': '/home/lroot',
     'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
     'PATH_INFO': u'/question/1141/this-is-a-test-of-adding-a-question234',
     'PWD': '/home/lroot/sap_hana_answers_server/server',
     'PYTHONPATH': ':/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages',
     'QUERY_STRING': '',
     'REMOTE_ADDR': '10.48.241.43',
     'REMOTE_HOST': '',
     'REQUEST_METHOD': 'GET',
     'RUN_MAIN': 'true',
     'SCRIPT_NAME': u'',
     'SERVER_NAME': 'george.pal.sap.corp',
     'SERVER_PORT': '8000',
     'SERVER_PROTOCOL': 'HTTP/1.1',
     'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.3rc1',
     'SHELL': '/bin/bash',
     'SHLVL': '1',
     'SSH_CLIENT': '10.48.241.43 64953 22',
     'SSH_CONNECTION': '10.48.241.43 64953 10.48.171.221 22',
     'SSH_TTY': '/dev/pts/0',
     'TERM': 'xterm',
     'TZ': 'Europe/Berlin',
     'USER': 'lroot',
     'XDG_SESSION_COOKIE': '13ff287091c3db8e81d4af57000001e8-1364584454.735821-20045594',
     '_': '/usr/local/bin/python',
     'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fefd8385270>,
     'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x1db6bb0>,
     'wsgi.input': <socket._fileobject object at 0x7fefc804b3d0>,
     'wsgi.multiprocess': False,
     'wsgi.multithread': True,
     'wsgi.run_once': False,
     'wsgi.url_scheme': 'http',
     'wsgi.version': (1, 0)}>)
    request
    "<WSGIRequest\npath:/question/1141/this-is-a-test-of-adding-a-question234,\nGET:<QueryDict: {}>,\nPOST:<QueryDict: {}>,\nCOOKIES:{'csrftoken': 'PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ',\n 'sessionid': 'e939f0325dd83398e572dbf63aa48581'},\nMETA:{'CONTENT_LENGTH': '',\n 'CONTENT_TYPE': 'text/plain',\n 'DJANGO_SETTINGS_MODULE': 'server.settings',\n 'GATEWAY_INTERFACE': 'CGI/1.1',\n 'HOME': '/home/lroot',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',\n 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',\n 'HTTP_CACHE_CONTROL': 'max-age=0',\n 'HTTP_CONNECTION': 'keep-alive',\n 'HTTP_COOKIE': 'csrftoken=PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ; sessionid=e939f0325dd83398e572dbf63aa48581',\n 'HTTP_HOST': '10.48.171.221:8000',\n 'HTTP_REFERER': 'http://10.48.171.221:8000/ask',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22',\n 'LANG': 'en_US.UTF-8',\n 'LESSCLOSE': '/usr/bin/lesspipe %s %s',\n 'LESSOPEN': '| /usr/bin/lesspipe %s',\n 'LOGNAME': 'lroot',\n 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:',\n 'MAIL': '/var/mail/lroot',\n 'OLDPWD': '/home/lroot',\n 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',\n 'PATH_INFO': u'/question/1141/this-is-a-test-of-adding-a-question234',\n 'PWD': '/home/lroot/sap_hana_answers_server/server',\n 'PYTHONPATH': ':/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '10.48.241.43',\n 'REMOTE_HOST': '',\n 'REQUEST_METHOD': 'GET',\n 'RUN_MAIN': 'true',\n 'SCRIPT_NAME': u'',\n 'SERVER_NAME': 'george.pal.sap.corp',\n 'SERVER_PORT': '8000',\n 'SERVER_PROTOCOL': 'HTTP/1.1',\n 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.3rc1',\n 'SHELL': '/bin/bash',\n 'SHLVL': '1',\n 'SSH_CLIENT': '10.48.241.43 64953 22',\n 'SSH_CONNECTION': '10.48.241.43 64953 10.48.171.221 22',\n 'SSH_TTY': '/dev/pts/0',\n 'TERM': 'xterm',\n 'TZ': 'Europe/Berlin',\n 'USER': 'lroot',\n 'XDG_SESSION_COOKIE': '13ff287091c3db8e81d4af57000001e8-1364584454.735821-20045594',\n '_': '/usr/local/bin/python',\n 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fefd8385270>,\n 'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x1db6bb0>,\n 'wsgi.input': <socket._fileobject object at 0x7fefc804b3d0>,\n 'wsgi.multiprocess': False,\n 'wsgi.multithread': True,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>"
    the_func
    <function __call__ at 0x7fefc0065c08>
    kwargs
    {'id': u'1141', 'slug': u'this-is-a-test-of-adding-a-question234'}
  • /usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py in _wrapped_view_func
    1. def never_cache(view_func):
    2.     """
    3.     Decorator that adds headers to a response so that it will
    4.     never be cached.
    5.     """
    6.     @wraps(view_func, assigned=available_attrs(view_func))
    7.     def _wrapped_view_func(request, *args, **kwargs):
    1.         response = view_func(request, *args, **kwargs)
      ...
    1.         add_never_cache_headers(response)
    2.         return response
    3.     return _wrapped_view_func
    ```
    Variable Value
    args
    (<WSGIRequest
    ```
    
    path:/question/1141/this-is-a-test-of-adding-a-question234,
    GET:<QueryDict: {}>,
    POST:<QueryDict: {}>,
    COOKIES:{'csrftoken': 'PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ',
     'sessionid': 'e939f0325dd83398e572dbf63aa48581'},
    META:{'CONTENT_LENGTH': '',
     'CONTENT_TYPE': 'text/plain',
     'DJANGO_SETTINGS_MODULE': 'server.settings',
     'GATEWAY_INTERFACE': 'CGI/1.1',
     'HOME': '/home/lroot',
     'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8',
     'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,_;q=0.3',
     'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
     'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
     'HTTP_CACHE_CONTROL': 'max-age=0',
     'HTTP_CONNECTION': 'keep-alive',
     'HTTP_COOKIE': 'csrftoken=PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ; sessionid=e939f0325dd83398e572dbf63aa48581',
     'HTTP_HOST': '10.48.171.221:8000',
     'HTTP_REFERER': 'http://10.48.171.221:8000/ask',
     'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22',
     'LANG': 'en_US.UTF-8',
     'LESSCLOSE': '/usr/bin/lesspipe %s %s',
     'LESSOPEN': '| /usr/bin/lesspipe %s',
     'LOGNAME': 'lroot',
     'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:_.tar=01;31:_.tgz=01;31:_.arj=01;31:_.taz=01;31:_.lzh=01;31:_.lzma=01;31:_.tlz=01;31:_.txz=01;31:_.zip=01;31:_.z=01;31:_.Z=01;31:_.dz=01;31:_.gz=01;31:_.lz=01;31:_.xz=01;31:_.bz2=01;31:_.bz=01;31:_.tbz=01;31:_.tbz2=01;31:_.tz=01;31:_.deb=01;31:_.rpm=01;31:_.jar=01;31:_.war=01;31:_.ear=01;31:_.sar=01;31:_.rar=01;31:_.ace=01;31:_.zoo=01;31:_.cpio=01;31:_.7z=01;31:_.rz=01;31:_.jpg=01;35:_.jpeg=01;35:_.gif=01;35:_.bmp=01;35:_.pbm=01;35:_.pgm=01;35:_.ppm=01;35:_.tga=01;35:_.xbm=01;35:_.xpm=01;35:_.tif=01;35:_.tiff=01;35:_.png=01;35:_.svg=01;35:_.svgz=01;35:_.mng=01;35:_.pcx=01;35:_.mov=01;35:_.mpg=01;35:_.mpeg=01;35:_.m2v=01;35:_.mkv=01;35:_.webm=01;35:_.ogm=01;35:_.mp4=01;35:_.m4v=01;35:_.mp4v=01;35:_.vob=01;35:_.qt=01;35:_.nuv=01;35:_.wmv=01;35:_.asf=01;35:_.rm=01;35:_.rmvb=01;35:_.flc=01;35:_.avi=01;35:_.fli=01;35:_.flv=01;35:_.gl=01;35:_.dl=01;35:_.xcf=01;35:_.xwd=01;35:_.yuv=01;35:_.cgm=01;35:_.emf=01;35:_.axv=01;35:_.anx=01;35:_.ogv=01;35:_.ogx=01;35:_.aac=00;36:_.au=00;36:_.flac=00;36:_.mid=00;36:_.midi=00;36:_.mka=00;36:_.mp3=00;36:_.mpc=00;36:_.ogg=00;36:_.ra=00;36:_.wav=00;36:_.axa=00;36:_.oga=00;36:_.spx=00;36:*.xspf=00;36:',
     'MAIL': '/var/mail/lroot',
     'OLDPWD': '/home/lroot',
     'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
     'PATH_INFO': u'/question/1141/this-is-a-test-of-adding-a-question234',
     'PWD': '/home/lroot/sap_hana_answers_server/server',
     'PYTHONPATH': ':/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages',
     'QUERY_STRING': '',
     'REMOTE_ADDR': '10.48.241.43',
     'REMOTE_HOST': '',
     'REQUEST_METHOD': 'GET',
     'RUN_MAIN': 'true',
     'SCRIPT_NAME': u'',
     'SERVER_NAME': 'george.pal.sap.corp',
     'SERVER_PORT': '8000',
     'SERVER_PROTOCOL': 'HTTP/1.1',
     'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.3rc1',
     'SHELL': '/bin/bash',
     'SHLVL': '1',
     'SSH_CLIENT': '10.48.241.43 64953 22',
     'SSH_CONNECTION': '10.48.241.43 64953 10.48.171.221 22',
     'SSH_TTY': '/dev/pts/0',
     'TERM': 'xterm',
     'TZ': 'Europe/Berlin',
     'USER': 'lroot',
     'XDG_SESSION_COOKIE': '13ff287091c3db8e81d4af57000001e8-1364584454.735821-20045594',
     '_': '/usr/local/bin/python',
     'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fefd8385270>,
     'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x1db6bb0>,
     'wsgi.input': <socket._fileobject object at 0x7fefc804b3d0>,
     'wsgi.multiprocess': False,
     'wsgi.multithread': True,
     'wsgi.run_once': False,
     'wsgi.url_scheme': 'http',
     'wsgi.version': (1, 0)}>,)
    request
    <webapp.views.QuestionResource object at 0x7fefc00630d0>
    view_func
    <function __call__ at 0x7fefc0065b90>
    kwargs
    {'id': u'1141', 'slug': u'this-is-a-test-of-adding-a-question234'}
  • /home/lroot/sap_hana_answers_server/server/webapp/views.py in __call__
    1.     @never_cache
    2.     def __call__(self, request, id=None, **kwargs):
    3.         if id is None and request.method == 'GET':
    4.             return self.read_all(request)
    5.         elif id is None and request.method == 'POST':
    6.             return self.create(request)
    7.         elif id is not None and request.method == 'GET':
    1.             return self.read(request, id)
      ...
    1.         elif id is not None and (request.POST.get("_method","") == "delete" or request.method == 'DELETE'):
    2.             return self.delete(request, id)
    3.         elif id is not None and request.method == 'POST':
    4.             return self.update(request, id)
    5.         else:
    6.             return HttpResponse('INVALID METHOD', status=405)
    Variable Value
    self
    <webapp.views.QuestionResource object at 0x7fefc00630d0>
    request
    "<WSGIRequest\npath:/question/1141/this-is-a-test-of-adding-a-question234,\nGET:<QueryDict: {}>,\nPOST:<QueryDict: {}>,\nCOOKIES:{'csrftoken': 'PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ',\n 'sessionid': 'e939f0325dd83398e572dbf63aa48581'},\nMETA:{'CONTENT_LENGTH': '',\n 'CONTENT_TYPE': 'text/plain',\n 'DJANGO_SETTINGS_MODULE': 'server.settings',\n 'GATEWAY_INTERFACE': 'CGI/1.1',\n 'HOME': '/home/lroot',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',\n 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',\n 'HTTP_CACHE_CONTROL': 'max-age=0',\n 'HTTP_CONNECTION': 'keep-alive',\n 'HTTP_COOKIE': 'csrftoken=PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ; sessionid=e939f0325dd83398e572dbf63aa48581',\n 'HTTP_HOST': '10.48.171.221:8000',\n 'HTTP_REFERER': 'http://10.48.171.221:8000/ask',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22',\n 'LANG': 'en_US.UTF-8',\n 'LESSCLOSE': '/usr/bin/lesspipe %s %s',\n 'LESSOPEN': '| /usr/bin/lesspipe %s',\n 'LOGNAME': 'lroot',\n 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:',\n 'MAIL': '/var/mail/lroot',\n 'OLDPWD': '/home/lroot',\n 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',\n 'PATH_INFO': u'/question/1141/this-is-a-test-of-adding-a-question234',\n 'PWD': '/home/lroot/sap_hana_answers_server/server',\n 'PYTHONPATH': ':/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '10.48.241.43',\n 'REMOTE_HOST': '',\n 'REQUEST_METHOD': 'GET',\n 'RUN_MAIN': 'true',\n 'SCRIPT_NAME': u'',\n 'SERVER_NAME': 'george.pal.sap.corp',\n 'SERVER_PORT': '8000',\n 'SERVER_PROTOCOL': 'HTTP/1.1',\n 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.3rc1',\n 'SHELL': '/bin/bash',\n 'SHLVL': '1',\n 'SSH_CLIENT': '10.48.241.43 64953 22',\n 'SSH_CONNECTION': '10.48.241.43 64953 10.48.171.221 22',\n 'SSH_TTY': '/dev/pts/0',\n 'TERM': 'xterm',\n 'TZ': 'Europe/Berlin',\n 'USER': 'lroot',\n 'XDG_SESSION_COOKIE': '13ff287091c3db8e81d4af57000001e8-1364584454.735821-20045594',\n '_': '/usr/local/bin/python',\n 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fefd8385270>,\n 'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x1db6bb0>,\n 'wsgi.input': <socket._fileobject object at 0x7fefc804b3d0>,\n 'wsgi.multiprocess': False,\n 'wsgi.multithread': True,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>"
    id
    u'1141'
    kwargs
    {'slug': u'this-is-a-test-of-adding-a-question234'}
  • /home/lroot/sap_hana_answers_server/server/webapp/views.py in read
    1.             return HttpResponseRedirect("/")
    2.         question = question[0]
    3.         user = request.user if request.user.is_authenticated() else None
    4.         rel_questions = self._get_related_questions(int(id)) # [q.as_dict() for q in self._get_related_questions(int(id))]
    5.         
    6.         rel_tags = Set(question.tags.all())
    1.         for q in rel_questions:
      ...
    1.             for tag in q.tags.all():
    2.                 rel_tags.add(tag)
    3.         question.views += 1
    4.         question.save()
    Variable Value
    question
    <Question: 1141/This is a test of adding a question234>
    self
    <webapp.views.QuestionResource object at 0x7fefc00630d0>
    rel_tags
    Set([<Tag: question2>])
    request
    "<WSGIRequest\npath:/question/1141/this-is-a-test-of-adding-a-question234,\nGET:<QueryDict: {}>,\nPOST:<QueryDict: {}>,\nCOOKIES:{'csrftoken': 'PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ',\n 'sessionid': 'e939f0325dd83398e572dbf63aa48581'},\nMETA:{'CONTENT_LENGTH': '',\n 'CONTENT_TYPE': 'text/plain',\n 'DJANGO_SETTINGS_MODULE': 'server.settings',\n 'GATEWAY_INTERFACE': 'CGI/1.1',\n 'HOME': '/home/lroot',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',\n 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',\n 'HTTP_CACHE_CONTROL': 'max-age=0',\n 'HTTP_CONNECTION': 'keep-alive',\n 'HTTP_COOKIE': 'csrftoken=PrC9gyWXl2yHEU9zOOTV4jvEUJz5c6QZ; sessionid=e939f0325dd83398e572dbf63aa48581',\n 'HTTP_HOST': '10.48.171.221:8000',\n 'HTTP_REFERER': 'http://10.48.171.221:8000/ask',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22',\n 'LANG': 'en_US.UTF-8',\n 'LESSCLOSE': '/usr/bin/lesspipe %s %s',\n 'LESSOPEN': '| /usr/bin/lesspipe %s',\n 'LOGNAME': 'lroot',\n 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:',\n 'MAIL': '/var/mail/lroot',\n 'OLDPWD': '/home/lroot',\n 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',\n 'PATH_INFO': u'/question/1141/this-is-a-test-of-adding-a-question234',\n 'PWD': '/home/lroot/sap_hana_answers_server/server',\n 'PYTHONPATH': ':/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '10.48.241.43',\n 'REMOTE_HOST': '',\n 'REQUEST_METHOD': 'GET',\n 'RUN_MAIN': 'true',\n 'SCRIPT_NAME': u'',\n 'SERVER_NAME': 'george.pal.sap.corp',\n 'SERVER_PORT': '8000',\n 'SERVER_PROTOCOL': 'HTTP/1.1',\n 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.3rc1',\n 'SHELL': '/bin/bash',\n 'SHLVL': '1',\n 'SSH_CLIENT': '10.48.241.43 64953 22',\n 'SSH_CONNECTION': '10.48.241.43 64953 10.48.171.221 22',\n 'SSH_TTY': '/dev/pts/0',\n 'TERM': 'xterm',\n 'TZ': 'Europe/Berlin',\n 'USER': 'lroot',\n 'XDG_SESSION_COOKIE': '13ff287091c3db8e81d4af57000001e8-1364584454.735821-20045594',\n '_': '/usr/local/bin/python',\n 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fefd8385270>,\n 'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x1db6bb0>,\n 'wsgi.input': <socket._fileobject object at 0x7fefc804b3d0>,\n 'wsgi.multiprocess': False,\n 'wsgi.multithread': True,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>"
    rel_questions
    <RawQuerySet: '\n        SELECT q.* FROM\n        webapp_question q INNER JOIN ( \n            SELECT wqt2.question_id, count(*) as count\n            FROM webapp_question_tags wqt1, webapp_question_tags wqt2\n            WHERE wqt1.tag_id=wqt2.tag_id \n            AND wqt1.question_id <> wqt2.question_id\n            AND wqt1.question_id = 1141\n            GROUP BY wqt2.question_id\n        ) qt2 ON qt2.question_id = q.post_ptr_id\n        ORDER BY qt2.count DESC\n        LIMIT 0, 10\n    '>
    user
    <django.utils.functional.SimpleLazyObject object at 0x7fefb045ebd0>
    id
    u'1141'
  • /usr/local/lib/python2.7/dist-packages/django/db/models/query.py in __iter__
    1.         # Cache some things for performance reasons outside the loop.
    2.         db = self.db
    3.         compiler = connections[db].ops.compiler('SQLCompiler')(
    4.             self.query, connections[db], db
    5.         )
    6.         need_resolv_columns = hasattr(compiler, 'resolve_columns')
    1.         query = iter(self.query)
      ...
    1.         # Find out which columns are model's fields, and which ones should be
    2.         # annotated to the model.
    3.         for pos, column in enumerate(self.columns):
    4.             if column in self.model_fields:
    5.                 model_init_field_names[self.model_fields[column].attname] = pos
    Variable Value
    annotation_fields
    []
    model_init_field_names
    {}
    db
    'default'
    need_resolv_columns
    False
    self
    <RawQuerySet: '\n        SELECT q.* FROM\n        webapp_question q INNER JOIN ( \n            SELECT wqt2.question_id, count(*) as count\n            FROM webapp_question_tags wqt1, webapp_question_tags wqt2\n            WHERE wqt1.tag_id=wqt2.tag_id \n            AND wqt1.question_id <> wqt2.question_id\n            AND wqt1.question_id = 1141\n            GROUP BY wqt2.question_id\n        ) qt2 ON qt2.question_id = q.post_ptr_id\n        ORDER BY qt2.count DESC\n        LIMIT 0, 10\n    '>
    compiler
    <django.db.backends.hana.compiler.SQLCompiler object at 0x7fefb045eed0>
  • /usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py in __iter__
    1.         converter = connections[self.using].introspection.table_name_converter
    2.         return [converter(column_meta[0])
    3.                 for column_meta in self.cursor.description]
    4.     def __iter__(self):
    5.         # Always execute a new query for a new iterator.
    6.         # This could be optimized with a cache at the expense of RAM.
    1.         self._execute_query()
      ...
    1.         if not connections[self.using].features.can_use_chunked_reads:
    2.             # If the database can't use chunked reads we need to make sure we
    3.             # evaluate the entire query up front.
    4.             result = list(self.cursor)
    5.         else:
    6.             result = self.cursor
    Variable Value
    self
    <RawQuery: '\n        SELECT q.* FROM\n        webapp_question q INNER JOIN ( \n            SELECT wqt2.question_id, count(*) as count\n            FROM webapp_question_tags wqt1, webapp_question_tags wqt2\n            WHERE wqt1.tag_id=wqt2.tag_id \n            AND wqt1.question_id <> wqt2.question_id\n            AND 
    ```            
            
                
    kapilratnani commented 11 years ago
    SELECT 
        q.* 
    FROM        
        webapp_question q 
    INNER JOIN (
        SELECT 
            wqt2.question_id, count(*) as count            
        FROM 
            webapp_question_tags wqt1, webapp_question_tags wqt2
        WHERE 
            wqt1.tag_id=wqt2.tag_id 
            AND wqt1.question_id <> wqt2.question_id            
            AND wqt1.question_id = 1141            
        GROUP BY wqt2.question_id
            ) qt2 ON qt2.question_id = q.post_ptr_id       
    ORDER BY 
        qt2.count DESC
    LIMIT 0, 10
    

    Same as issue3 try executing the above query directly in HANA Studio. Also HANA doesn't support LIMIT clause of this form. It should be "LIMIT N , OFFSET M"(It didn't work for me last time, i remember).

    george-quaye-sap-com commented 11 years ago

    Using>>> SELECT q._FROM webapp_question q INNER JOIN ( SELECT wqt2.questionid, count() as count FROM webapp_question_tags wqt1, webapp_question_tags wqt2 WHERE wqt1.tag_id=wqt2.tag_id AND wqt1.question_id <> wqt2.question_id AND wqt1.question_id = 1141 GROUP BY wqt2.question_id ) qt2 ON qt2.question_id = q.post_ptr_id ORDER BY qt2.count DESC LIMIT 0 OFFSET 10

    Returned>>> Statement 'SELECT q._FROM webapp_question q INNER JOIN ( SELECT wqt2.questionid, count() as count FROM ...' successfully executed in 5 ms 994 µs (server processing time: 0 ms 168 µs) Fetched 0 row(s) in 0 ms 0 µs (server processing time: 0 ms 0 µs)

    From: Kapil Ratnani [mailto:notifications@github.com] Sent: Friday, March 29, 2013 2:38 PM To: kapilratnani/django_hana Cc: Quaye, George Subject: Re: [django_hana] Save Error (#2)

    SELECT q.* FROM

    webapp_question q INNER JOIN ( SELECT wqt2.question_id, count(*) as count

    FROM webapp_question_tags wqt1, webapp_question_tags wqt2 WHERE wqt1.tag_id=wqt2.tag_id AND wqt1.question_id <> wqt2.question_id

    AND wqt1.question_id = 1141

    GROUP BY wqt2.question_id ) qt2 ON qt2.question_id = q.post_ptr_id

    ORDER BY qt2.count DESC LIMIT 0, 10

    Same as issue3 try executing the above query directly in HANA Studio. Also HANA doesn't support LIMIT clause of this form. It should be "LIMIT N , OFFSET M"(It didn't work for me last time, i remember).

    — Reply to this email directly or view it on GitHubhttps://github.com/kapilratnani/django_hana/issues/2#issuecomment-15661878.

    george-quaye-sap-com commented 11 years ago

    In the views.py of the application, the query was hard coded, "OUCH"... so, after finding this I set the syntax

    class QuestionResource(Resource):

    related_questions_query = '''
        SELECT q.* FROM
        webapp_question q INNER JOIN ( 
            SELECT wqt2.question_id, count(*) as count
            FROM webapp_question_tags wqt1, webapp_question_tags wqt2
            WHERE wqt1.tag_id=wqt2.tag_id 
            AND wqt1.question_id <> wqt2.question_id
            AND wqt1.question_id = %s
            GROUP BY wqt2.question_id
        ) qt2 ON qt2.question_id = q.post_ptr_id
        ORDER BY qt2.count DESC
        LIMIT 0 OFFSET 10
    '''