problem about pyramid-Collection of common programming errors


  • gcb
    python pylons pyramid
    What problems can I have if I will use python 2.7 instead python 2.6 for my pylons/pyramid projects? Before I use python 2.6 on my ubuntu 10.04 but now I have ubuntu 11.04 on my laptop with python 2.7.

  • Martijn Pieters
    html dreamweaver pyramid chameleon template-tal
    I’m starting to learn web development and am using pyramid with chameleon. I just took some sites html source as a template in Dreamweaver and then copied the code into a chameleon .pt file.The html code displays fine in dreamweaver but I get this error when running it in pyramid: chameleon.exc.ParseError ParseError: Unexpected end tag.- String: “</div>”I have tried dreamweavers cleanup function and it said it removed 2 empty tags but I still get this error. My traceback is all rela

  • Tshepang
    python google-app-engine pyramid
    Using pyramid_appengine my project works fine but, when i deploy to GAE i have this error:Traceback (most recent call last):File “/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py”, line 187, in Handlehandler = _config_handle.add_wsgi_middleware(self._LoadHandler())File “/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py”, line 225, in _LoadHandlerhandler = __import__(path[0])File “/base/data/home/apps/s~muncompy/v3.359898035587494190/mu

  • Tshepang
    python wsgi pyramid
    INTROI’ve recently switched to Python, after about 10 years of PHP development and habits.Eg. in Symfony2, every request to server (Apache for instance) has to load eg. container class and instantiate it, to construct the “rest” of the objects.As far as I understand (I hope) Python’s WSGI env, an app is created once, and until that app closes, every request just calls methods/functions.This means that I can have eg. one instance of some class, that can be accessed every time, request is dispatch

  • timbo
    python google-app-engine pyramid
    I am using Pyramid 1.3 with the AppEngine 1.6.4 SDK on OS X 10.7.3. I am using Python 2.7 and have threadsafe true in app.yaml.@view_config(route_name=’manager_swms’, permission=’manager’, renderer=’manager/swms.jinja2′) def manager_swms(request):”””Generates blobstore url and passes users swms in swms table”””# generate url for any form upload that may occurupload_url = blobstore.create_upload_url(‘/upload_swm’)user = get_current_user(request)swms = DBSession.query(SWMS).filter_by(owner_id=int(

  • Tshepang
    python plugins pyramid
    I’d like to know how to edit pyramid registry at runtime. Well i’m not so sure exactly what I have to edit. I know I can extend pyramid with config.include(…). But once config.make_wsgi_app() is called, there seems to be no way to add routes or new mako directories. Any change to the registery in threadlocals or settings have no effect on how the app behave. My goal is to add plugin at runtime. Here’s a use case. Someone install my appserver running pyramid…then install some pluginspip insta

  • Docent
    python google-app-engine pylons pyramid
    I’m trying to run Pyramid on GAE by following the steps outlined here. Everything works fine on dev server, but when deployed to Google’s servers, the following error occurs:<type ‘exceptions.ImportError’>: cannot import name BaseRequest Traceback (most recent call last):File “/base/data/home/apps/…/0-0-1.353634463095353211/main.py”, line 9, in <module>from pyramid.config import ConfiguratorFile “/base/data/home/apps/…/0-0-1.353634463095353211/lib/dist/pyramid/__init__.py”, line

  • GhotiPhud
    python sqlalchemy pyramid paster
    I’ve defined a new Column type called File, which should let me store only the file name in the database. Then I would store the actual file in the file system at root+subfolder+name.File(root, subfolder=””, max_length=100, **kwargs)The problem I’m having is that I’d like to define the root in a PasteDeploy config file. How do I define this at runtime so I can access the configuration?

  • user1509750
    python pyramid renderer
    Pyramid offers a beforeRendererfrom repoze.events import subscriberfrom pyramid.events import BeforeRender@subscriber(BeforeRender)def add_global(event):print event[‘renderer_name’] #this is the renderer nameprint event[‘renderer_info’].name #same with event[‘renderer_name’]But not useful. If I change or delete the event[‘renderer_name’] and event[‘renderer_info’].name, it can also find the renderer(a template file) in config.config.add_view(‘mywork.views.index.index’,route_name=’/index’,re

  • Madawar
    python pyramid
    I am creating a blog engine that will require a user to enter the configuration of the engine in production.ini, I want to create a user interface that allows the user to enter the settings of his/her blogI can already get the current settings from production/development.ini using event[‘theme’] = settings[‘theme’] event[‘blogname’] = settings[‘blogname’]But i also want to be able to get the path of the development/production.ini or the path of the current configuration file that is being used a

  • BDuelz
    python pyramid
    In pyramid, I need to render my templates according to different runtime environments — enable google analytics, use minified code, etc. (when in production). Is there an easy way to find out the current environment — perhaps an existing flag to find out which ini file was used?

  • Tshepang
    python pyramid static-files
    In a pyramid application, I defined a static view for serving css/js files and another one to serve others datas like uploaded files:config.add_static_view(‘static’, ‘static’, cache_max_age=3600) config.add_static_view(‘uploads’, path=’/data/uploads’)On the template side, i’m using request.static_url() to access to static files:<script type=”text/javascript” src=”${request.static_url(‘myapp:static/js/jquery-1.8.3.min.js’)}”></script>The problem is I don’t know how to use request.stat

  • Aviv
    python crash paste pyramid chameleon
    I have a Pyramid application that uses Chameleon as its template engine. I have one (quite large, but I have had larger) template that will just not work. Whenever I try to render it to return as a view, paste server development.ini crashes miserably without any errors (Mac OS X’s terminal tells me “bus error”). When I run the exact same code on my server with apache and mod_wsgi, everything works great. How do I even start figuring out whats wrong?

  • Tshepang
    python eclipse pydev pyramid waitress
    I’m trying to setup a working IDE and starting to learn Python with Pyramid framework in a friendly environment like Eclipse/Pydev.All is working ok (debug, breakpoints included) if I use the old pastescript server by replacing:use = egg:waitress#main –> use = egg:Paste#http in development.ini.The problem is that the new “way to go” is to use waitress which is supported in Python 3+ versions and pastescript only works on 2.x.I would want to know if there is any kind of known issue debugging

  • blahdiblah
    python eclipse debugging pyramid
    I’m getting started with Pyramid development on Windows. I have Python 2.7 installed. I used virtualenv to create a nice sandbox for my Pyramid app. I also created PyDev 2.4 on Eclipse Indigo. I also created a separate PyDev interpreter just for my virutalenv, so it should have access to all the directories. I set up a new debug configuration.Project: testapp (the only project in the workspace) Main module: ${workspace_loc:testapp/Scripts/pserve-script.py} Args: development.ini Working dir: Othe

  • Taras Voynarovsky
    python views pyramid error-logging
    Task: When an error occurs in one of my views I need to show a custom error view. The error type does not matter.I tried to override all exceptions by registring a view for all exceptions, like this:<viewcontext=”Exception”renderer=”server_error.pt”/>It worked good. All exceptions were showing my view. But the problem was that those errors stopped logging. Of cource I can do something like logger.error(traceback) in my error view, but this is a dumb idea.How can I register a view for all e

  • sidewinder
    python pylons pyramid
    I have the following code for the view:def pages_view(request):path = request.path.split(‘/’)[1]dbsession = DBSession()page = dbsession.query(PagesTable).from_statement(‘SELECT * FROM pages WHERE path=:page_path’).params(page_path=path).first()pages_dir = os.getcwd() + ‘/myblog/templates/pages/’if page:if path == ”:return render_to_response(‘myblog:templates/pages/home.mak’,{‘page’:page}, request=request)elif os.path.isfile(pages_dir + path + ‘.mak’):return render_to_response(‘myblog:templates/

  • fynn
    python reflection sqlalchemy pyramid
    I am currently working on a pyramid system that uses sqlalchemy.This system will include a model (let’s call it Base) that is stored in a database table. This model should be extensible by the user on runtime. Basically, the user sould be able to subclass the Base and create a new model (let’s call this one ‘Child’). Childs should be stored in another database table.All examples available seem to handle database reflection on a predefined model. What would be the best way to generate complete mo

  • Martijn Pieters
    python json pyramid chameleon
    Here is the view callable for my home page that defines jsdata: @view_config(route_name=’home_page’, renderer=’templates/edit.pt’) def home_page(request):if ‘form.submitted’ in request.params:name= request.params[‘name’]input_file=request.POST[‘stl’].filenamevertices, normals = [],[]for line in input_file:….ordering=[]…parsing data…data=[vertices,ordering]jsdata=json.dumps(data)renderer_dict = dict(name=name,data=jsdata)…html_string = render(‘tutorial:templates/view.pt’, renderer_dict

  • JeffCompton
    python django-templates pyramid mako
    We had this code and it worked fine. After doing a refactor, it doesn’t work anymore. Like the comment says, we only want to inherit from a base page if the request isn’t an ajax request. To do this, we pass a parameter to the template, and, based on the parameter, we inherit or not.View.pyclass Router(object):def __init__(self, request):self.request = request@view_config(route_name=”home”)def get(self):template = “home.mak”value = {‘isPage’:self.request.is_xhr is False}return render_to_respo

  • Tshepang
    python pyramid mako
    I have this Pyramid view:def ClientView(request):session = request.sessionsession[‘selectedclientid’] = ‘test’ #selectedclient.idsession.save()return dict(logged_in=authenticated_userid(request))And then in my template I’m just trying something like this:% if session[‘selectedclientid’] != None:The session has something% endifAnd this gives me a template error:% if session[‘selectedclientid’] != None: TypeError: ‘Undefined’ object has no attribute ‘__getitem__’Am I setting the session variable w

  • Mark
    pyramid mako
    I’m using Pyramid 1.3 with Mako Templating. I have a view with a method called “create” that returns an empty dictionary to a template. I intend to use the same “create.mako” template for both creating and editing. I’ve put the context variable like such in my input fields:<input type=”text” id=”nameInput” value=”${content[‘name’]}” />The problem with this is that I get errors like below when I try to load the create method:<input id=”nameInput” value=”${content[‘name’]}” type=”text”

  • Gino
    python pyramid
    When I attempt to run pyramid [~/env/MyStore]# ../bin/pserve development.iniIt will show the following errorFile “/home/vretinfo/env/lib/python3.2/site-packages/Paste-1.7.5.1-py3.2.egg/paste/fileapp.py”, line 14, in <module>from paste.httpheaders import * File “/home/vretinfo/env/lib/python3.2/site-packages/Paste-1.7.5.1-py3.2.egg/paste/httpheaders.py”, line 140, in <module>from rfc822 import formatdate, parsedate_tz, mktime_tz ImportError: No module named rfc822How should I resolve

Web site is in building