Skip to content
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

Cannot view /feeds after updating to latest code. #71

Closed
cleverdevil opened this issue Jul 24, 2014 · 7 comments
Closed

Cannot view /feeds after updating to latest code. #71

cleverdevil opened this issue Jul 24, 2014 · 7 comments
Assignees
Labels
Milestone

Comments

@cleverdevil
Copy link

I get the following stack trace:

Traceback (most recent call last):
  File "/home/dhc-user/coldsweat/coldsweat/app.py", line 110, in __call__
    app_iter = self.app(environ, start_response)

  File "/home/dhc-user/coldsweat/coldsweat/cascade.py", line 99, in __call__
    return last_app(environ, start_response)

  File "/home/dhc-user/coldsweat/coldsweat/session.py", line 86, in __call__
    return self.app(environ, start_response)

  File "/home/dhc-user/coldsweat/coldsweat/app.py", line 64, in __call__
    response = handler(self, self.request, *args)

  File "/home/dhc-user/coldsweat/coldsweat/frontend.py", line 30, in wrapper
    return handler(self, request, *args)

  File "/home/dhc-user/coldsweat/coldsweat/frontend.py", line 269, in feed_list
    return self.respond_with_template('feeds.html', locals())

  File "/home/dhc-user/coldsweat/coldsweat/frontend.py", line 433, in respond_with_template
    render_template(filename, namespace),

  File "/home/dhc-user/coldsweat/coldsweat/frontend.py", line 517, in render_template
    return Template.from_filename(path.join(template_dir, filename), namespace=namespace).substitute()

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 177, in substitute
    result = self._interpret_inherit(result, defs, inherit, ns)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 204, in _interpret_inherit
    return templ.substitute(ns)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 177, in substitute
    result = self._interpret_inherit(result, defs, inherit, ns)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 204, in _interpret_inherit
    return templ.substitute(ns)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 173, in substitute
    result, defs, inherit = self._interpret(ns)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 184, in _interpret
    self._interpret_codes(self._parsed, ns, out=parts, defs=defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 212, in _interpret_codes
    self._interpret_code(item, ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 236, in _interpret_code
    out.append(self._repr(base, pos))

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 334, in _repr
    value = coerce_text(value)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/compat3.py", line 44, in coerce_text
    return bytes(v)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 522, in __str__
    return self()

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 532, in __call__
    self._template._interpret_codes(self._body, ns, out, subdefs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 212, in _interpret_codes
    self._interpret_code(item, ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 236, in _interpret_code
    out.append(self._repr(base, pos))

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 334, in _repr
    value = coerce_text(value)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/compat3.py", line 44, in coerce_text
    return bytes(v)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 522, in __str__
    return self()

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 532, in __call__
    self._template._interpret_codes(self._body, ns, out, subdefs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 212, in _interpret_codes
    self._interpret_code(item, ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 229, in _interpret_code
    self._interpret_if(parts, ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 287, in _interpret_if
    self._interpret_codes(part[3], ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 212, in _interpret_codes
    self._interpret_code(item, ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 232, in _interpret_code
    base = self._eval(parts[0], ns, pos)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 294, in _eval
    value = eval(code, self.default_namespace, ns)

  File "<string>", line 1, in <module>

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 532, in __call__
    self._template._interpret_codes(self._body, ns, out, subdefs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 212, in _interpret_codes
    self._interpret_code(item, ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 226, in _interpret_code
    self._interpret_for(vars, expr, content, ns, out, defs)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/__init__.py", line 259, in _interpret_for
    for item in expr:

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/_looper.py", line 42, in __iter__
    return looper_iter(self.seq)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/tempita/_looper.py", line 52, in __init__
    self.seq = list(seq)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/peewee.py", line 2139, in __iter__
    return iter(self.execute())

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/peewee.py", line 2132, in execute
    self._qr = ResultWrapper(model_class, self._execute(), query_meta)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/peewee.py", line 1838, in _execute
    return self.database.execute_sql(sql, params, self.require_commit)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/peewee.py", line 2414, in execute_sql
    self.commit()

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/peewee.py", line 2283, in __exit__
    reraise(new_type, new_type(*exc_value.args), traceback)

  File "/home/dhc-user/.virtualenvs/coldsweat/local/lib/python2.7/site-packages/peewee.py", line 2406, in execute_sql
    cursor.execute(sql, params or ())

ProgrammingError: column "t2.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ..._checked_on", t1."last_status", t1."error_count", t2."id", t...
                                                             ^
 at line 49 column 19 in file /home/dhc-user/coldsweat/coldsweat/templates/feeds.html at line 5 column 11 in file /home/dhc-user/coldsweat/coldsweat/templates/index.html at line 37 column 7 in file /home/dhc-user/coldsweat/coldsweat/templates/site.html
@passiomatic
Copy link
Owner

Are you using the code from the 0.9.3 release (which is current master codebase)? It looks like the /feeds query has been improperly written.

Also, which version of Pewee and database backend are you using?

@cleverdevil
Copy link
Author

Yes, on master:

(coldsweat)dhc-user@feeds:~/coldsweat$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   .gitignore
#   modified:   coldsweat/app.py
#

Installed packages:

(coldsweat)dhc-user@feeds:~/coldsweat$ pip freeze
Tempita==0.5.1
WebOb==1.3.1
argparse==1.2.1
distribute==0.6.34
feedparser==5.1.3
gunicorn==18.0
peewee==2.2.5
psycopg2==2.5.2
requests==2.3.0
wsgiref==0.1.2

I am using PostgreSQL:

(coldsweat)dhc-user@feeds:~/coldsweat$ psql --version
psql (PostgreSQL) 9.1.11

HTH!

@passiomatic
Copy link
Owner

Cannot reproduce the problem with a fresh installation cloned from master. I tried both with SQLite and MySQL. Unfortunately right now I cannot test with PostgreSQL.

I was running Peewee 2.2.3, but even after the upgrade to version 2.2.5 things ran smoothly.

Can you reproduce the error with SQLite?

@cleverdevil
Copy link
Author

Just tried to reproduce in sqlite, and could not. It appears to be a Peewee issue with PostgreSQL.

@passiomatic
Copy link
Owner

Ha! I think I figured out what the problem is. I'll fix & test more thoroughly in the next release. However, in the meantime if you want to patch by yourself open up coldsweat/frontend.py file and at line 555 replace the get_feeds() function with:

def get_feeds(user, *select):  
    select = select or [Feed, Icon, fn.Count(Entry.id).alias('entries')]
    q = Feed.select(*select).join(Icon).switch(Feed).join(Entry, JOIN_LEFT_OUTER).switch(Feed).join(Subscription).where(Subscription.user == user).group_by(Feed, Icon)
    return q  

@passiomatic passiomatic added this to the 0.9.4 milestone Jul 25, 2014
@passiomatic passiomatic self-assigned this Jul 25, 2014
@cleverdevil
Copy link
Author

That indeed did work. Its a bit slow, but at least its not crashing now :)

@passiomatic
Copy link
Owner

The good news is that Icon model will be removed in the future (see #26) so we'll spare that join/group_by too.

passiomatic added a commit that referenced this issue Jul 29, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants