Repository: getpelican/pelican

Issue:
NoneType object has no attribute 'startswith' when creating a new project
Hi all,

Pelican looks really promising, but I cannot get it to run, unfortunately

Here is what I did:

mkvirtualenv pelican # virtualenvwrapper - this already sources "activate"
pip install --upgrade pelican # Make sure it's the latest from pip
touch article.rst # also, added some actual rst to it
pelican .

Gives me:
Traceback (most recent call last):
  File "/home/chris/.virtualenvs/pelican/bin/pelican", line 3, in <module>
    main()
  File "/home/chris/.virtualenvs/pelican/lib/python2.7/site-packages/pelican/**init**.py", line 129, in main
    settings = read_settings(args.settings)
  File "/home/chris/.virtualenvs/pelican/lib/python2.7/site-packages/pelican/settings.py", line 80, in read_settings
    if not os.path.isabs(context[path]):
  File "/home/chris/.virtualenvs/pelican/lib/python2.7/posixpath.py", line 53, in isabs
    return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'

Out of spite, I also tried with the quickstart script suggested in #129, and while the script seems to work great, invoking make gives me the exact same traceback.

What am I doing wrong?

Cheers,
- Chris



Discussion:
Hello Chris, 
I'm also a newcomer to Pelican as it seems very promising and stuck as you are.
After a few testing, code-reading, I found out that even if the setting file is described as optional, it is required in the current pelican version. So if you do the following

touch empty.py
pelican . -s empty.py 

The generation should work just fine
Maybe someone more experienced in pelican could confirm it is a bug.

Someone else reported the same issue on #pelican and I already fixed it (see the commits ac0b1a6f823777174a26d9ae402d9ae0b1a730c2 and 128867630252e05f3d557383a1b7539e7a78893c) 3 days ago. The reason you didn't notice it is because you installed and upgraded pelican via pip and my changes haven't been merged into a new version (yet). So use git to get the latest version, install it via `python setup.py install` (will require root previleges) and check if the error message appears again.

Oops, accidentally clicked "comment & close", sorry for that.


Resolving patch:
diff --git a/pelican/__init__.py b/pelican/__init__.py
--- a/pelican/__init__.py
+++ b/pelican/__init__.py
@@ -102,7 +102,7 @@ def main():
     parser.add_argument('-m', '--markup', default=None, dest='markup',
         help='the list of markup language to use (rst or md). Please indicate '
              'them separated by commas')
-    parser.add_argument('-s', '--settings', dest='settings',
+    parser.add_argument('-s', '--settings', dest='settings', default='',
         help='the settings of the application. Default to False.')
     parser.add_argument('-d', '--delete-output-directory', dest='delete_outputdir',
         action='store_true', help='Delete the output directory.')
@@ -124,8 +124,6 @@ def main():
     # the variable with None.
     markup = [a.strip().lower() for a in args.markup.split(',')] if args.markup else None
 
-    if args.settings is None:
-        settings = {}
     settings = read_settings(args.settings)
 
     cls = settings.get('PELICAN_CLASS')


Test patch: