262: import failures with backup-db.py

philippe********@gmai***** (Google Code) (Is this you? Claim this profile.)
Nov. 10, 2007
Here's what I'm trying to run:

PYTHONPATH=$PWD/django:$PWD/reviews/ python ./contrib/db/backup-db.py >
new-data.json

I get this error:

Traceback (most recent call last):
  File "./contrib/db/backup-db.py", line 33, in <module>
    import reviewboard.accounts.models as accounts
  File "/home/phil/reviewboard/accounts/models.py", line 6, in <module>
    from reviewboard.reviews.models import Group, ReviewRequest
  File "/home/phil/reviewboard/reviews/models.py", line 15, in <module>
    from utils.templatetags.htmlutils import crop_image, thumbnail
  File "/usr/lib/python2.5/site-packages/utils.py", line 25, in <module>
    import commands, encodings.ascii, encodings.utf_8, encodings.latin_1, \
  File "/home/phil/reviewboard/reviews/email.py", line 5, in <module>
    from django.core.mail import EmailMessage
  File "/home/phil/reviewboard/django/django/core/mail.py", line 7, in <module>
    from email import Charset, Encoders
ImportError: cannot import name Charset

In fact I think the email module from reviews package conflicts with stdlib
email module.
david
#1 david
Why are you including ./reviews in your pythonpath?  That's probably what's messing
you up.
  • +NeedInfo
#2 philippe********@gmai***** (Google Code) (Is this you? Claim this profile.)
If I don't include ./reviews I get this:

Traceback (most recent call last):
  File "./contrib/db/backup-db.py", line 33, in <module>
    import reviewboard.accounts.models as accounts
  File "/home/phil/reviewboard/accounts/models.py", line 6, in <module>
    from reviewboard.reviews.models import Group, ReviewRequest
  File "/home/phil/reviewboard/reviews/models.py", line 15, in <module>
    from utils.templatetags.htmlutils import crop_image, thumbnail
ImportError: No module named templatetags.htmlutils

Maybe that import should be made absolute? from reviews.utils.templatetags... ?
chipx86
#3 chipx86
It probably should. I don't know why it's not. If you make that change, does it work?
#4 philippe********@gmai***** (Google Code) (Is this you? Claim this profile.)
Yeah in models.py if I do:

from reviewboard.utils.templatetags.htmlutils import crop_image, thumbnail

instead of 

from utils.templatetags.htmlutils import crop_image, thumbnail

it works
chipx86
#5 chipx86
  • -NeedInfo
    +Fixed
  • +Component-Scripts