Following Pylons sample code regarding the "helpers", there's the following snippet:
${h.form(h.url(action='email'), method='get')}
Email Address: ${h.text('email')}
${h.submit('Submit')}
${h.end_form()}
However, apparently, there's no url method in WebHelpers as the server throws AttributeError: 'module' object has no attribute 'url'.
Am I doing something wrong? If no, what is the equivalent of url()?
Somehow obscure for someone new to Pylons. It should have been mentioned in the docs, IMHO.
The answer to "Mocking away the url object in Pylons", has my answer. I need from pylons import url in helpers.py.
Related
I'm trying to order a firestore collection by the field name, but it's giving me this error: AttributeError: 'CollectionReference' object has no attribute 'orderBy'.
My code:
participants_ref = db.collection("participants")
docs = participants_ref.orderBy("name").stream()
In case this helps, I've also printed out participants_ref and I get the following:
<google.cloud.firestore_v1.collection.CollectionReference object at 0x0000021C9EAB7F40>
According to the documentation, the method you're looking for is order_by. Be sure to switch the code language tab to "Python" to see the correct usage.
docs = participants_ref.order_by("name").stream()
Also see the python API documentation for CollectionReference.
I'm using https://github.com/sigmavirus24/github3.py
and I'm having problem with getting issue_comments from PR.
for pr in repo.iter_pulls():
for comment in pr.issue_comments():
print comment
I'm getting
AttributeError: 'PullRequest' object has no attribute
'issue_comments'
What I'm doing wrong here? review_comments for example is working just fine
The review_comments method was added very recently and was backported from the next planned version of github3.py (1.0). When it was backported, to reduce migration headaches from 0.9.x to 1.0, we decided to not prefix it with iter_ like the other similar methods. In short, the method you are looking for is: iter_issue_comments.
The following should work
TEMPLATE = """{0.user} commented on #{0.number} at {0.created_at} saying:
{0.body}
"""
for pr in repo.iter_pulls()
for comment in pr.iter_issue_comments():
print(TEMPLATE.format(comment))
I am total newbie with cherrypy.
My setup: Arch Linux, Python 3.3, tornado, cherrypy 3.2
Trying to implement session handling for a web app using cherrypy.lib.sessions (for some reason often referred to as cherrypy.sessions in various forums, might be another version)
I am looking for an example of the following:
instantiate a session object
set a value of an arbitrarily named attribute
write session into a session file
read session info from session file
access the the value of the modified attribute
My (relevant) code:
import cherrypy
class RequestHandlerSubmittedRequest(tornado.web.RequestHandler):
def get(self):
SetState(self)
def SetState(self):
cherrypy.config.update({'tools.sessions.on': True})
cherrypy.config.update({'tools.sessions.storage_type': 'file'})
#directory does exist
cherrypy.config.update({'tools.sessions.storage_path': '/tmp/cherrypy_sessions'})
cherrypy.config.update({'tools.sessions.timeout': 60})
cherrypy.config.update({'tools.sessions.name': 'hhh'})
So far so good. Now:
obj_session = cherrypy.lib.sessions.FileSession
Here I get the first snag (or misunderstanding).
The returned obj_session contains no session ID of any kind, just an empty object frame. Also: no file is created at this point in /tmp/cherrypy_sessions -
should not it be there now? I would expect it to be created and named after its session ID.
OK, no ID in the object, let's assign one:
session_id = obj_session.generate_id(self)
This returns a long random string as it should I guess
And now I don't know how to proceed with assignments and saving calling obj_session.save() or obj_session.load() with several variations of input gives "AttributeError: 'module' object has no attribute X" where X can be "load" and couple of other keywords. Passing self or obj_session itself to the methods does not help, just changes the wording of the error. I must be going in a very wrong direction in general.
So, is there an example of those five steps above? I could not find one anywhere.
Thanks.
Igor
I'd like to read outside the current namespace with something like the following:
some_entity = MyModel.get_by_id(some_id_name, namespace='somenamespace')
but get_by_id doesn't take namespace as a parameter. I get:
TypeError: Unknown configuration option ('namespace')
I've gotten things to work with:
some_entity = ndb.Key(MyModel, some_id_name, namespace='somenamespace').get()
So now I'm just complaining, but I figured others could benefit from this. :) Also, since Guido monitors this, is there a reason for not allowing the namespace option in get_by_id?
EDIT: This is now possible in App Engine 1.7.0.
Please file a feature request in the NDB issue tracker: http://code.google.com/p/appengine-ndb-experiment/issues/list
you could first change the namespace and then you get the entity by_id
from google.appengine.api import namespace_manager
namespace_manager.set_namespace('thenamespace')
MyModel.get_by_id(some_id_name)
I am using djangos built in comments framework presented in this example: https://docs.djangoproject.com/en/1.3/ref/contrib/comments/example/
And there is a sample code of how to implement a basic comment submission form
{% render_comment_form for entry %}
and when I use this code i get an error that my news model doesent have "add_comment" attribute. but there's no word about it in the example so I am asking how this "add_comment" shoudl work ?
Caught ViewDoesNotExist while rendering: Tried add_comment in module news.views. Error was: 'module' object has no attribute 'add_comment'
You probably have an error in urls.py file in your "news" app. It seems like one of URL patterns there is referring to a non-existing "add_comment" function.
Did you added comments in urls.py?
like so:
url(r'^comments/', include('django.contrib.comments.urls')),