smug error

1 view
Skip to first unread message

Jonathan Wilson

unread,
Mar 26, 2009, 2:44:11 PM3/26/09
to smug...@googlegroups.com
So, on a fresh install of SMUG, i've noted the following things:

first - it is no longer SMUG_REPOSITORY in settings, it is now a
dictionary (?) called SMUG_REPOSITORIES (docs are old) (i'll submit a
patch later)

second, there is no mention of how to manually specify which filter you
would like (my old smug installation was pre- filter type days).

third, there is a bug somewhere, but smug seems to not do proper
traceback handling. any attempt at viewing a page now throws:

Exception Type: TypeError
Exception Value: show() takes at least 3 non-keyword arguments (2 given)

Exception Location:
/usr/lib/python2.6/site-packages/django/core/handlers/base.py in
get_response, line 86


Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in
get_response
92. response = middleware_method(request, e)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py"
in get_response
86. response = callback(request, *callback_args,
**callback_kwargs)

Exception Type: TypeError at /wiki/
Exception Value: show() takes at least 3 non-keyword arguments (2
given)

I still haven't been able to figure out where this is coming from. the
only show() i could find was in smug/views/show, and the only file
calling it was raw.py. however, adding a raise Exception to the raw.py
before it calls show() did not result in a different exception being
raised. just fyi.
--
Jonathan Wilson

Andrew McNabb

unread,
Mar 26, 2009, 3:08:16 PM3/26/09
to smug...@googlegroups.com
On Thu, Mar 26, 2009 at 12:44:11PM -0600, Jonathan Wilson wrote:
>
> So, on a fresh install of SMUG, i've noted the following things:
>
> first - it is no longer SMUG_REPOSITORY in settings, it is now a
> dictionary (?) called SMUG_REPOSITORIES (docs are old) (i'll submit a
> patch later)

I thought that had been fixed already--a patch would be great.


> second, there is no mention of how to manually specify which filter you
> would like (my old smug installation was pre- filter type days).

If we don't have .smug documentation, then we certainly need to add it.
We can at least start with some email messages I've sent to the list.
I'll have to look into this.


> third, there is a bug somewhere, but smug seems to not do proper
> traceback handling. any attempt at viewing a page now throws:
>
> Exception Type: TypeError
> Exception Value: show() takes at least 3 non-keyword arguments (2 given)
>
> Exception Location:
> /usr/lib/python2.6/site-packages/django/core/handlers/base.py in
> get_response, line 86
>
>
> Traceback:
> File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in
> get_response
> 92. response = middleware_method(request, e)
> File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py"
> in get_response
> 86. response = callback(request, *callback_args,
> **callback_kwargs)
>
> Exception Type: TypeError at /wiki/
> Exception Value: show() takes at least 3 non-keyword arguments (2
> given)
>
> I still haven't been able to figure out where this is coming from. the
> only show() i could find was in smug/views/show, and the only file
> calling it was raw.py. however, adding a raise Exception to the raw.py
> before it calls show() did not result in a different exception being
> raised. just fyi.

Hmm. I haven't run into this, so I'm wondering what could be different.
Could you send your urls.py?

--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868

Jeff Anderson

unread,
Mar 26, 2009, 3:16:22 PM3/26/09
to smug...@googlegroups.com
This happens if you don't give the name of the repo as an arg when
including the smug urls in your urls.py.

urlpatterns += smug.urls.urlpatterns

should now be:

urlpatterns += patterns('',
(r'^', include('smug.urls'), {'repo': 'content'}),
)

where 'content' is the key of the repo given in the dictionary of
SMUG_REPOSITORIES.

Jeff Anderson

signature.asc

Jonathan Wilson

unread,
Mar 26, 2009, 4:06:18 PM3/26/09
to smug...@googlegroups.com
On Thu, Mar 26, 2009 at 01:16:22PM -0600, Jeff Anderson wrote:
> Andrew McNabb wrote:
> >
> > Hmm. I haven't run into this, so I'm wondering what could be different.
> > Could you send your urls.py?
> >
> This happens if you don't give the name of the repo as an arg when
> including the smug urls in your urls.py.
>
> urlpatterns += smug.urls.urlpatterns
>
> should now be:
>
> urlpatterns += patterns('',
> (r'^', include('smug.urls'), {'repo': 'content'}),
> )
>
> where 'content' is the key of the repo given in the dictionary of
> SMUG_REPOSITORIES.
>
> Jeff Anderson
>

Yeah, that worked. the docs should probably be updated for that too -
its currently:


If you want to use Smug for your whole site, change urls.py in your
project to include:

(r'', include('smug.urls'))

If you have some sublocation for it, then the line should look like:

(r'^(?P<basepath>where/smug/goes/)', include('smug.urls'))


I could probably fix that as well in the patch i'll send ya.

Also, is there now something different than what is in the docs for
using a custom template? I have (in my git repo) a templates folder,
with wiki.html inside for my wiki template.

ie, /path/to/bare/repo.git, a checkout of which has templates/wiki.html

my settings has

SMUG_TEMPLATE = 'wiki.html'

and TEMPLATE_DIRS has

'git:///templates'

(also tried /git/templates, which was what it used to be)

'smug.extras.load_template_source' is in the proper template_loaders as
well

however, smug doesn't find the template, and just displays the base
page. what's missing?

thanks.

--
Jonathan Wilson

Jeff Anderson

unread,
Mar 26, 2009, 4:33:33 PM3/26/09
to smug...@googlegroups.com
Jonathan Wilson wrote:
> and TEMPLATE_DIRS has
> 'git:///templates'
>
it is now:

smug://<reponame>/path/to/templates


> 'smug.extras.load_template_source' is in the proper template_loaders as
> well
>

That looks right.

signature.asc

Jonathan Wilson

unread,
Mar 26, 2009, 5:51:21 PM3/26/09
to smug...@googlegroups.com
On Thu, Mar 26, 2009 at 02:33:33PM -0600, Jeff Anderson wrote:
> it is now:
>
> smug://<reponame>/path/to/templates
> > 'smug.extras.load_template_source' is in the proper template_loaders as
> > well
> >
> That looks right.
>

it still isn't loading the template. since it also isn't interpreting
the <!-- title:

portion, i'm guessing i need to set the filter as
extendtemplate/present. however, the doc's do not currently say how.
so. how? :p

--
Jonathan Wilson

Jonathan Wilson

unread,
Mar 26, 2009, 6:33:13 PM3/26/09
to smug...@googlegroups.com
On Thu, Mar 26, 2009 at 03:51:21PM -0600, Jonathan Wilson wrote:
>
> it still isn't loading the template. since it also isn't interpreting
> the <!-- title:
>
> portion, i'm guessing i need to set the filter as
> extendtemplate/present. however, the doc's do not currently say how.
> so. how? :p
>

So, it does work if I add the rst rst2html bit from the docs (at least
that is there) and convert my files to rst. apparantly this is a good
opportunity to update my site to rst, heh

--
Jonathan Wilson

Jonathan Wilson

unread,
Mar 26, 2009, 6:46:16 PM3/26/09
to smug...@googlegroups.com
On Thu, Mar 26, 2009 at 04:33:13PM -0600, Jonathan Wilson wrote:
>
> So, it does work if I add the rst rst2html bit from the docs (at least
> that is there) and convert my files to rst. apparantly this is a good
> opportunity to update my site to rst, heh
>

Also, it appears that the syntax for smugmenu has left the docs behind
as well. the docs say {{ smug_menu }}, it is {{ smugmenu }}, however,
that shows <smug.menu.SmugMenu object at 0x9ac890c>, and it isn't
registered as a valid block, so that doesn't work either. Would someone
mind telling me what the new syntax to call the menu is?

thanks.

--
Jonathan Wilson

Jeff Anderson

unread,
Mar 26, 2009, 7:13:30 PM3/26/09
to smug...@googlegroups.com
{% for i in smugmenu %}<li><a href="{{i.1}}">{{i.0}}</a></li>{% endfor %}


I've been meaning to update the docs to reflect all these changes for a
while now. I'm more than happy if you beat me to it.

signature.asc

Jonathan Wilson

unread,
Mar 26, 2009, 8:55:57 PM3/26/09
to smug...@googlegroups.com
On Thu, Mar 26, 2009 at 05:13:30PM -0600, Jeff Anderson wrote:
> {% for i in smugmenu %}<li><a href="{{i.1}}">{{i.0}}</a></li>{% endfor %}
>
>
> I've been meaning to update the docs to reflect all these changes for a
> while now. I'm more than happy if you beat me to it.
>

K, thanks. Its up and running now (had to convert my whole site to rst,
but luckily my whole site isn't very big).

one thing i've noticed - the ssl middleware doesn't seem to work very
well - with secure cookies turned on, and the ssl middleware in
middleware, after a login, it redirects to http, and any attempt to go
to https redirects back to http. as far as the menu goes, it doesn't
update with the changing of login. if i click login from the menu, and
then log in, the menu says log in, and i am in fact not logged in. (i
check by trying to go to /admin). if i log in via another django app,
and then go to my smug url, the full smug menu is present. however, if
i then click on logout, i get logged out, but the refreshed menu still
shows me as being logged in.

this isn't really a concern for me since i almost always edit on the
command line, and since it appears that the text area doesn't correctly
do rst files (it drops all the extra new line characters, which rst
doesn't really like very much), but I thought I'd let you all know.

--
Jonathan Wilson

James Carroll

unread,
Mar 27, 2009, 11:38:47 AM3/27/09
to smug...@googlegroups.com
you updated to rest from what? html? If so, here is how you get html to work:

your .smug should look something like this:

# Sample .smug file

# When a directory is requested, return the content from index.html:
directory_index index.html

convert from .html to .html using present
convert from .rst to .html using rst2html

Then, if you also want to over-ride the default template in some
sub-directory of your page add this in your .smug:

# When a directory is requested, return the content from index.html:
template newtemplatename.html

all directories under that will over-ride the default template.... the
default template information should be set in your settings.py and
smug.config.py like this:

settings.py:

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'smug.extras.smug_load_template_source',
)

As I understand the above, the first two parts tells django how to
handle templates, and the last one tells it how to get templates out
of a git repository (I think you don't need the last one if your
template is in a directory that has a nohandler set in apache, so that
it doesn't come off of smug, which can speed things up a bit, but then
you can't handle your template in your git repo)

Then you need:

TEMPLATE_DIRS = (
'smug://jlcarroll/templates',
#'/home/jlc/gitworking/jlcarroll/templates',
)

That gives you the directory to look in, use smug:// or http://
depending on where you put it.

Then in smug.config.py there should be a line like:

DEFAULT_TEMPLATE = 'template.html'

that gives the name of the default template that will be used unless
over-ridden by the .smug file.

The docs really need to be updated....

Hope this helps and isn't all info you already had, because you
shouldn't have had to convert your entire web page to rest.

Good luck,

James
--
"And very early in the morning
the first day of the week,
they came unto the sepulchre
at the rising of the sun..." (Mark 16:2)

Web: http://james.jlcarroll.net

Jonathan Wilson

unread,
Mar 27, 2009, 3:14:55 PM3/27/09
to smug...@googlegroups.com
On Fri, Mar 27, 2009 at 09:38:47AM -0600, James Carroll wrote:
>
> convert from .html to .html using present

this was the only thing that I didn't have, or hadn't figured out. it
isn't anywhere in the docs, and I didn't feel like looking through the
source to find out how to do that. since convert from .rst to .html
using rst2html, i converted all my site from .html to .rst to get it to
work. it was in my to do list anyway, so its not that big of a deal.

--
Jonathan Wilson

Andrew McNabb

unread,
Mar 27, 2009, 3:17:47 PM3/27/09
to smug...@googlegroups.com
On Fri, Mar 27, 2009 at 01:14:55PM -0600, Jonathan Wilson wrote:
>
> this was the only thing that I didn't have, or hadn't figured out. it
> isn't anywhere in the docs, and I didn't feel like looking through the
> source to find out how to do that. since convert from .rst to .html
> using rst2html, i converted all my site from .html to .rst to get it to
> work. it was in my to do list anyway, so its not that big of a deal.

Yeah, we definitely need to go through and update the docs. There are a
lot of errors like this, and it's a shame to have the documentation lie.

Jeff Anderson

unread,
Jun 12, 2009, 1:40:10 PM6/12/09
to smug...@googlegroups.com
On Thu, Mar 26, 2009 at 12:44:11PM -0600, Jonathan Wilson wrote:
> first - it is no longer SMUG_REPOSITORY in settings, it is now a
> dictionary (?) called SMUG_REPOSITORIES (docs are old) (i'll submit a
> patch later)

Hello,

I went to update the doc where this change would need to be made, and it
looks like your patch hasn't made it in. If you have it ready, I'll wait
until it's merged before doing mine to avoid conflicts for either one of
us.

I created a feature, and my docs will depend on those docs being done.
If you haven't already written the patch to update the docs, I'm more
than happy to do that part. I just didn't want to duplicate effort where
it would be avoided.


Jeff Anderson

Reply all
Reply to author
Forward
0 new messages