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

Build fails with UUID in permalink (Py3k) #130

Closed
dmdm opened this issue Aug 21, 2012 · 3 comments
Closed

Build fails with UUID in permalink (Py3k) #130

dmdm opened this issue Aug 21, 2012 · 3 comments
Assignees
Milestone

Comments

@dmdm
Copy link

dmdm commented Aug 21, 2012

In a Python 3.2 virtual env, building the site fails when permalink uses UUID (e.g. blog.auto_permalink.path = ":blog_path/:uuid"). Traceback is:

Traceback (most recent call last):
  File "/home/dm/myprojects/blogofile-env/bin/blogofile", line 9, in <module>
    load_entry_point('Blogofile==0.8-DEV', 'console_scripts', 'blogofile')()
  File "/home/dm/myprojects/blogofile-env/bf_src/blogofile/main.py", line 58, in main
    args.func(args)
  File "/home/dm/myprojects/blogofile-env/bf_src/blogofile/main.py", line 388, in do_build
    writer.write_site()
  File "/home/dm/myprojects/blogofile-env/bf_src/blogofile/writer.py", line 49, in write_site
    self.__run_controllers()
  File "/home/dm/myprojects/blogofile-env/bf_src/blogofile/writer.py", line 162, in __run_controllers
    controller.run_all(namespaces)
  File "/home/dm/myprojects/blogofile-env/bf_src/blogofile/controller.py", line 229, in run_all
    c.mod.run()
  File "/home/dm/myprojects/blogofile-env/bf_blog_src/blogofile_blog/site_src/_controllers/blog/__init__.py", line 62, in run
    blog.posts = post.parse_posts(blog.post.source_dir)
  File "/home/dm/myprojects/blogofile-env/bf_blog_src/blogofile_blog/site_src/_controllers/blog/post.py", line 405, in parse_posts
    p = Post(src, filename=post_fn)
  File "/home/dm/myprojects/blogofile-env/bf_blog_src/blogofile_blog/site_src/_controllers/blog/post.py", line 109, in __init__
    self.__post_process()
  File "/home/dm/myprojects/blogofile-env/bf_blog_src/blogofile_blog/site_src/_controllers/blog/post.py", line 199, in __post_process
    blog_config.path, self.title, self.date, uuid, self.filename)
  File "/home/dm/myprojects/blogofile-env/bf_blog_src/blogofile_blog/site_src/_controllers/blog/post.py", line 374, in create_permalink
    permalink = re.sub(":uuid", uuid, permalink)
  File "/home/dm/myprojects/blogofile-env/lib/python3.2/re.py", line 170, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: sequence item 1: expected str instance, bytes found

Proposed solution:

Function bf_blog_src/blogofile_blog/site_src/_controllers/blog/post.py::create_guid() currently returns the GUID as bytes which breaks the RegEx later on.
Maybe we simply can convert the GUID to string, assuming the bytes are ASCII:

return base64.urlsafe_b64encode(hashlib.sha1(to_hash).digest()).decode('ascii')
@ghost ghost assigned douglatornell Aug 22, 2012
@douglatornell
Copy link
Collaborator

Thanks for spotting this. create_guid() is for sure an ugly bit of code. I think you are right that it should be able to return a string.

On my list to fix before 0.8 release.

@douglatornell
Copy link
Collaborator

Since this is actually a blogofile_blog issue, it will be tracked and resolved at EnigmaCurry/blogofile_blog#14.

@douglatornell
Copy link
Collaborator

Fixed in EnigmaCurry/blogofile_blog@372928e

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

No branches or pull requests

2 participants