Not run tgapp - turbopress

60 views
Skip to first unread message

Diego García

unread,
Jun 15, 2015, 6:54:48 PM6/15/15
to turbo...@googlegroups.com
Hi community!

I'm installing tgapp-turbopress. Delete the current database to generate the new with turbopress, add the line plug(base_config, 'turbopress') at config/app__cfg.py at the end of the file, run setup- app gearbox development.ini but I get the follow error.

(regina)diegogarcia@it-4:~/regina/regina$ gearbox setup-app -c development.ini

17:45:16,388 INFO  [tgext.pluggable] Plugging turbopress
Running setup_app() from regina.websetup
17:45:16,395 INFO  [tgapp-turbopress] Configuring Turbopress for SQLAlchemy
17:45:16,500 ERROR [tgext.pluggable] Failed to plug turbopress
Traceback (most recent call last):
  File "/home/diegogarcia/regina/local/lib/python2.7/site-packages/tgext/pluggable/plug.py", line 63, in plug
    self._plug_application(self.app_config, self.module_name, self.options)
  File "/home/diegogarcia/regina/local/lib/python2.7/site-packages/tgext/pluggable/plug.py", line 78, in _plug_application
    0
  File "/home/diegogarcia/regina/local/lib/python2.7/site-packages/turbopress/controllers/__init__.py", line 4, in <module>
    from .root import RootController
  File "/home/diegogarcia/regina/local/lib/python2.7/site-packages/turbopress/controllers/root.py", line 53, in <module>
    class RootController(TGController):
  File "/home/diegogarcia/regina/local/lib/python2.7/site-packages/turbopress/controllers/root.py", line 150, in RootController
    @validate(get_article_form(), error_handler=edit)
  File "/home/diegogarcia/regina/local/lib/python2.7/site-packages/turbopress/lib/forms.py", line 77, in get_article_form
    config = tg.config['_turbopress']
  File "/home/diegogarcia/regina/local/lib/python2.7/site-packages/tg/configuration/app_config.py", line 56, in __getitem__
    return self.config_proxy.current_conf()[key]
KeyError: '_turbopress'
17:45:16,508 ERROR [gearbox] 'NoneType' object has no attribute 'bind'

Alessandro Molina

unread,
Jun 16, 2015, 4:51:08 AM6/16/15
to TurboGears
Turbopress right now has not been ported to TG2.3.5 yet. 
As TG 2.3.5 changed how the config visibility works some pluggable apps might need minor changes to be able to work.

Porting them to TG2.3.5 is usually just a matter of few minutes, I'll try to have a look at porting Turbopress to TG2.3.5 in the next few days and I'll try to release a new turbopress version right after. In the mean time you might want to work with TG2.3.4 if you need to work on an app that depends on Turbopress.

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Diego García

unread,
Jun 16, 2015, 3:07:10 PM6/16/15
to turbo...@googlegroups.com
Hi Alessandro!

Perfect, I
've managed to do with tg2 2.3.4!
Thank you very much for the great help, I really hope that actulice all to enjoy benefits in the current version of tg2 2.3.5.

Alessandro Molina

unread,
Jun 16, 2015, 5:40:24 PM6/16/15
to TurboGears
Good,
I also rolled out turbopress 0.0.2 right now, which should be compatible with TG2.3.5 let me know if that solves your compatibility issues


Diego García

unread,
Jun 16, 2015, 6:59:18 PM6/16/15
to turbo...@googlegroups.com
Hi Alessandro!

It has been successful update and I managed to install tgapp-turbopress in tg2 2.3.5

Now I have another question, how do I manage to add pluggin for comments on the blog?

Waiting for your answer, thank you very much!



Diego García

unread,
Jun 16, 2015, 7:31:21 PM6/16/15
to turbo...@googlegroups.com
This is the link to download Bitbucket tgapp-tgcomments.

https://bitbucket.org/_amol_/tgapp-tgcomments


I want to install and the following error

(regina)diegogarcia@it-4:~/regina$ pip install tgcomments
Downloading/unpacking tgcomments
  Could not find any downloads that satisfy the requirement tgcomments
Cleaning up...
No distributions at all found for tgcomments
Storing debug log for failure in /home/diegogarcia/.pip/pip.log
(regina)diegogarcia@it-4:~/regina$

Alessandro Molina

unread,
Jun 17, 2015, 3:37:40 AM6/17/15
to TurboGears
pip install tgapp-tgcomments


I haven't tested it yet on 2.3.5, so if you find issues let me know.

Diego García

unread,
Jun 17, 2015, 11:14:53 AM6/17/15
to turbo...@googlegroups.com
Hi Alessandro!

When I install it there is no error. I added the lines as the tutorial presents it.

from tgext.pluggable import plug

The previous line was already included in the instant that I did for turbopress.

At the end of document app_cfg.py add lines.


plug(base_config, 'turbopress')
plug(base_config, 'tgcomments')


I delete the previous database and return again to run the command:

gearbox setup-app development.ini

http://localhost:8080/tgcomments

Get me "Error 404", as if don't run tgcomments, but do not mark error as if the repository is wrong.

What I'm doing wrong?

Thanks for your help



Alessandro Molina

unread,
Jun 17, 2015, 4:35:58 PM6/17/15
to TurboGears


On Wed, Jun 17, 2015 at 5:14 PM, Diego García <diegog...@gmail.com> wrote:

What I'm doing wrong?


Nothing, it's just the documentation that it is not very clear :D
I updated it on https://bitbucket.org/axant/tgapp-tgcomments to make it a little easier to follow.

tgcomments actually doesn't provide any page, so going to http://localhost:8080/tgcomments goes nowhere, you must call the "tgcomments.partials:comments_for(entity)" partial inside your template yo provide comments for the given entity.

That will render a section with a form to add a new comments and the list of previous comments.
For details on partials refer to https://github.com/TurboGears/tgext.pluggable#partials which explains what they are and how to use them

Hope this helps you!


Diego García

unread,
Jun 17, 2015, 6:27:07 PM6/17/15
to turbo...@googlegroups.com
Hi Alesssandro!

I understand you,
Apparently the code has an error:

file partials.py

@expose('genshi:turbopress.templates.articles_excerpts')
def excerpts(articles=None, blog=None):
    if articles is None:
        articles = model.Article.get_published(blog)
    return dict(articles=articles)


@expose('genshi:turbopress.templates.excerpt')
def excerpt(article):
    return article_preview(article)

Alessandro Molina

unread,
Jun 18, 2015, 2:15:28 AM6/18/15
to TurboGears
which error? can't see it, is something wrong with the snippet you posted?

--

Diego García

unread,
Jun 18, 2015, 11:27:48 AM6/18/15
to turbo...@googlegroups.com
I think that this part of the code is not correct should be the following:

@expose('genshi:turbopress.templates.excerpt')
def excerpt(article):
    return article_preview(article)



I think
that it should be in the following way:

@expose('genshi:turbopress.templates.article_excerpt')
def excerpt(article):
    return article_preview(article)


I'm not really an expert, but I changed the way and the result was correct.

When downloaded the package I saw that they were as well, I thought that I had altered it so I downloaded it again and the result was the same.


In addition the comments do not work very well, do you you to operated properly in the latest version of tg2 2.3.5?

Thank you for give me the freedom to express myself as a user, I hope to be able to contribute something good to the community.

Alessandro Molina

unread,
Jun 18, 2015, 5:50:21 PM6/18/15
to TurboGears
On Thu, Jun 18, 2015 at 5:27 PM, Diego García <diegog...@gmail.com> wrote:
I think that this part of the code is not correct should be the following:

@expose('genshi:turbopress.templates.excerpt')

I think
that it should be in the following way:

@expose('genshi:turbopress.templates.article_excerpt')

Ah yeah, thanks for pointing that.
As turbopress is actually a fork of smallpress it inherited the same bug and as I always ended up replacing the excerpt template with a custom one I never noticed it.

I released turbopress 0.0.3 which fixes the issue and has a set of test units for all the partials to check that all of them work.


In addition the comments do not work very well, do you you to operated properly in the latest version of tg2 2.3.5?

Dunno, I have not been using tgcomments for a few months, so it might be that it has issues with 2.3.5.
Which problems are you facing? 

Diego García

unread,
Jun 19, 2015, 2:26:14 PM6/19/15
to turbo...@googlegroups.com

I add form and the comments of each article.
Tg-turbopress article.html template I added the following lines:

${h.call_partial('turbopress.partials:article_preview', article=article)}
${h.call_partial('tgcomments.partials:comments_for(entity)')})

The first comes by default to print the article and the second line is to show the form and the comments of each article, but they don't show up!

Could you help me to tell me the right way that I put.

Also says the tutorial to the address http://localhost: 8080/tgcomments can access the registration process, have failed.



I again ask you to be so kind to help me, I think the documentation for use is low, it would be good to add more.

Thank you very much, your help is really useful!

Alessandro Molina

unread,
Jun 19, 2015, 4:10:27 PM6/19/15
to TurboGears
On Fri, Jun 19, 2015 at 8:26 PM, Diego García <diegog...@gmail.com> wrote:

Also says the tutorial to the address http://localhost: 8080/tgcomments can access the registration process, have failed.


That was just a stray paragraph in README as it was copied from "tgapp-registration" (that's why it talks about registration), there is no such page as http://localhost:8080/tgcomments
tgapp-tgcomments only provides partials, no pages.

Have a look at this example on code.runnable.com to see how you can easily join turbopress with comments using tgext.pluggable template patches:


(remember to login as manager with default quickstart password)
 

Diego García

unread,
Jun 19, 2015, 8:03:49 PM6/19/15
to turbo...@googlegroups.com
Ich habe nicht in der Lage, es zu erreichen, so dass Sie es vorschlagen.

Manchmal mark ich diesen Fehler:
OSError: [Errno 2] keine solche Datei oder das Verzeichnis: "/ home/diegogarcia/regina/local/lib/python2.7/site-packages/tgcomments/templates/comments_partial.mak"

Und bei anderen Gelegenheiten die folgenden:
AttributeError: Typ 'Undefined' Objekt hat kein Attribut '__mapper__'

Ich folge Schritt für Schritt die Runneable, aber ich erhalte es nicht.

Alessandro Molina

unread,
Jun 22, 2015, 3:02:32 AM6/22/15
to TurboGears
Sorry but my german is near to 0 ;)
I'll try to answer by the error messages

2015-06-20 2:03 GMT+02:00 Diego García <diegog...@gmail.com>:
Manchmal mark ich diesen Fehler:
OSError: [Errno 2] keine solche Datei oder das Verzeichnis: "/ home/diegogarcia/regina/local/lib/python2.7/site-packages/tgcomments/templates/comments_partial.mak"

Might it be that you specified mako as your template engine? Please take note that most pluggable apps only work with Genshi.
Usually only tgext.* work with different template engines, while tgapp-* only work with Genshi.
 
Und bei anderen Gelegenheiten die folgenden:
AttributeError: Typ 'Undefined' Objekt hat kein Attribut '__mapper__'

This is more obscure, some kind of error with your models that I'm unable to provide solution for without more data :/

Diego García

unread,
Jun 22, 2015, 12:12:38 PM6/22/15
to turbo...@googlegroups.com
I am using Mako templates, is it necessary to use Genshi to make comments work?

Blog have installed you with Mako and not it has caused me problems, as really I am stuck with the comments.

This is the error that get me, when I add the line
${h.call_partial('tgcomments.partials:comments_for', entity=article)}

in the template of article.html turbopress

TemplateLookupException: Cant locate template ' / home/diegogarcia/regina/local/lib/python2.7/site-packages/tgcomments/templates/comments_partial.mak'

But I do not understand that it is asking for a file named comments_partial.mak', what have to do with anything else?

Alessandro Molina

unread,
Jun 22, 2015, 12:22:22 PM6/22/15
to TurboGears
On Mon, Jun 22, 2015 at 6:12 PM, Diego García <diegog...@gmail.com> wrote:
I am using Mako templates, is it necessary to use Genshi to make comments work?

Usually tgapp-* have only been tested and work with Genshi. The more recent pluggable apps usually support being used from an app that uses another template engine while they continue to use Genshi, but that is not true for all of them. 
 
Blog have installed you with Mako and not it has caused me problems,

That's because as far as you have Genshi installed tubopress will use it, so your own pages will be in Mako while turbopress pages will be in Genshi.
You can freely mix them so there is no particular issue in doing that.
 
as really I am stuck with the comments.

This is the error that get me, when I add the line
${h.call_partial('tgcomments.partials:comments_for', entity=article)}

in the template of article.html turbopress

TemplateLookupException: Cant locate template ' / home/diegogarcia/regina/local/lib/python2.7/site-packages/tgcomments/templates/comments_partial.mak'

But I do not understand that it is asking for a file named comments_partial.mak', what have to do with anything else?

tgcomments asks for the "comments_partial" template and as you have mako as your default template engine TurboGears will look for the mako template named "comments_partial" which doesn't exist as tgcomments uses Genshi. That is because tgcomments doesn't specify the template engine that should be used inside partials, so your application default is used, which is Mako.

It should suffice to update tgapp-tgcomments to explicitly use Genshi independently from your app engine, so that while tgcomments uses genshi you can use it inside apps that use another template engine. I'll try to update that and roll out a new release this evening so you should be able to call tgcomments partials from your app even when you are not using mako. 

Just pay attention that tgcomments is probably not the only one that works only on Genshi, and while I'll gladly update the pluggable apps I have commit access to work on Mako too, there are some I'm not involved in which might not work on Mako too.

Diego García

unread,
Jun 22, 2015, 12:32:02 PM6/22/15
to turbo...@googlegroups.com
Alessandro I now understand, it is good idea to use two template engines, but I think it would be more free to be able to use one only.

If you were so kind of giving me their support with update comment and use it also for Mako would be great and a great contribution on their part.

Really thank you very much for your support at all times, is very responsible for their services.

Waiting for your update of tgapp-comments in mako, once again, thanks!

Alessandro Molina

unread,
Jun 22, 2015, 3:30:59 PM6/22/15
to TurboGears
I released tgapp-tgcoments 0.0.8 which will work also work in applications using Mako as far as you have genshi installed (so, if turbopress was working, tgcomments will too).


Diego García

unread,
Jun 23, 2015, 12:44:15 PM6/23/15
to turbo...@googlegroups.com
Many thanks Alessandro!

At this very moment I am creating a new project to work all about mako.

If you would like to work with two engines (mako and genshi) templates. how I say to tgapp-comments that it should work with genshi and do not take default mako?

I'm very sorry abuse of your disposition, but actually live intrigued with turbopress, well in this case with turbogears.

I would like that my user you can log in to fbauth. But the information they offer is not very enough. So I guess I must add the secret token of the app, but where I add it?

On this occasion could you help me with fbauth?

Once again, thanks!

Diego García

unread,
Jun 23, 2015, 2:05:08 PM6/23/15
to turbo...@googlegroups.com

I'm still in the login with fbauth and ontengo the following:



sqlalchemy.orm.exc.DetachedInstanceError
 

DetachedInstanceError: Parent instance <User at 0x7fcd134c0090> is not bound to a Session; lazy load operation of attribute 'fbauth' cannot proceed
Traceback (most recent call last)
 
 
File "/home/diegogarcia/regina/lib/python2.7/site-packages/tgcomments/templates/comments_partial.html", line 18, in <Expression u"h.tgcomments.get_user_avatar(request.identity['user'])"> <td><img style="height:32px;"
 
 
File "/home/diegogarcia/regina/lib/python2.7/site-packages/tgcomments/lib/__init__.py", line 20, in get_user_avatar fbauth = getattr(user, 'fbauth', None)
 
 
File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/attributes.py", line 237, in __get__ return self.impl.get(instance_state(instance), dict_)
 
 
File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/attributes.py", line 578, in get value = self.callable_(state, passive)
 
 
File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/strategies.py", line 501, in _load_for_state (orm_util.state_str(state), self.key)
 
DetachedInstanceError: Parent instance <User at 0x7fcd134c0090> is not bound to a Session; lazy load operation of attribute 'fbauth' cannot proceed



Diego García

unread,
Jun 24, 2015, 5:35:56 PM6/24/15
to turbo...@googlegroups.com
Thank you for all your support Alessandro!
Your tips were very helpful for my project's website and blog only using TurboGears and plug-ins.

Alessandro Molina

unread,
Jun 26, 2015, 3:57:15 AM6/26/15
to TurboGears
You have the User instance which is already expunged from the session.

Look for lib/base.py in your project and at the end of BaseController.__call__ add:

try:
    request.identity['user'] = model.DBSession.merge(request.identity['user'])
except:
    request. identity = None

Let me know if this is enough to solve your problem.

On Tue, Jun 23, 2015 at 8:05 PM, Diego García <diegog...@gmail.com> wrote:

I'm still in the login with fbauth and ontengo the following:
sqlalchemy.orm.exc.DetachedInstanceError
 

DetachedInstanceError: Parent instance <User at 0x7fcd134c0090> is not bound to a Session; lazy load operation of attribute 'fbauth' cannot proceed
Traceback (most recent call last)
 




Reply all
Reply to author
Forward
0 new messages