Dear All,

I am new to pylons and python, need help with a problem that I have.
Sorry if my question sounds silly.
I am learning through the pylons book, currently working on chapter 8.
I am using pylons 1.0 and formbuild 3.0 and mako. Therefore I modified
the code to suit the packages by referring to the codes available in
the posts and internet.

While executing http://localhost:5000/page/new, I received an error of
AttributeError: 'function' object has no attribute 'replace'. It seems
that the coding below ( in new.html) is the source of the error.

${h.form.start_with_layout(h.url(controller='page',
action='create'),method='post')}

However it wont be an error if I use start_layout() function instead.
${h.form.start_layout(h.url(controller='page', action='create'))}

I am using the start_with_layout() because it is illustrated in the
book examples. Am I missing something?
By the way, another question, how do I specify the textarea cols and
rows in formbuild3. I cant find the example in doing that.

The coding and the errors notification is shown below.

TQ in Advance.

________________________________________
Form is in "forms" module-->

from formbuild import Form
from webhelpers.html import literal

class LiteralForm(Form):
    def __getattribute__(self, name):
        if name in ['value', 'option', 'error', 'checked', 'flow']:
            return Form.__getattribute__(self, name)
        def make_literal(*k, **p):
            return literal(getattr(Form, name)(self, *k, **p))
        return make_literal


_____________________________________________________

helpers.py -->

from webhelpers.html.tags import *
from simplesite.forms import LiteralForm
from pylons import url

form = LiteralForm(
    value={
        'heading':u'',
        'title':u'',
        'content':u''
    }
)
_______________________________________

fields.html -->

${h.form.field(
    label="Heading",
    type='text',
    name='heading',
    required=False,
)}
${h.form.field(
    label="Title",
    type='text',
    name='title',
    required=True,
    field_desc = "Used as the heading too if you didn't specify one
above"
)}
${h.form.field(
    label="Content",
    type='textarea',
    name='content',
    required=True,
    field_desc = 'The text that will make up the body of the page'
)}

______________________________________________________
new.html-->

<%inherit file="/base/index.html" />
<%namespace file="fields.html" name="fields" import="*"/>

<%def name="heading()">
    <h1 class="main">Create a New Page</h1>
</%def>

form.start_with_layout(h.url(controller='page',
action='create'),method='post')}
    ${fields.body()}
    ${h.form.action_bar(h.form.submit(value="Create Page",
name='submit'))}
${h.form.end_layout()}

______________________________________________________
Error notifications --->


AttributeError: 'function' object has no attribute 'replace'

5 <h1 class="main">Create a New Page</h1>
6 </%def>
7
8 ${h.form.start_with_layout(h.url(controller='page',
action='create'),method='post')}
9 ${fields.body()}
10 ${h.form.action_bar(h.form.submit(value="Create Page",
name='submit'))}
11 ${h.form.end_layout()}
12

/usr/lib/python2.5/cgi.py, line 1055:
s = s.replace("&", "&amp;") # Must be done first!
/tomyapp/mydevenv/lib/python2.5/site-packages/FormBuild-3.0.3-
py2.5.egg/formbuild/__init__.py, line 188:
return html + u'<table class="%s">'%(escape(table_class or
self.table_class))
/tomyapp/SimpleSite/simplesite/forms.py, line 9:
return literal(getattr(Form, name)(self, *k, **p))
/tomyapp/SimpleSite/simplesite/templates/derived/page/new.html, line
8:
${h.form.start_with_layout(h.url(controller='page',
action='create'),method='post')}
/tomyapp/SimpleSite/simplesite/templates/base/index.html, line 16:
${next.body()}
/tomyapp/mydevenv/lib/python2.5/site-packages/Mako-0.3.6-py2.5.egg/
mako/runtime.py, line 626:
callable_(context, *args, **kwargs)
/tomyapp/mydevenv/lib/python2.5/site-packages/Mako-0.3.6-py2.5.egg/
mako/runtime.py, line 637:
result = template.error_handler(context, error)
/tomyapp/mydevenv/lib/python2.5/site-packages/Mako-0.3.6-py2.5.egg/
mako/runtime.py, line 628:
_render_error(template, context, e)
/tomyapp/mydevenv/lib/python2.5/site-packages/Mako-0.3.6-py2.5.egg/
mako/runtime.py, line 607:
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
/tomyapp/mydevenv/lib/python2.5/site-packages/Mako-0.3.6-py2.5.egg/
mako/runtime.py, line 575:
**_kwargs_for_callable(callable_, data))
/tomyapp/mydevenv/lib/python2.5/site-packages/Mako-0.3.6-py2.5.egg/
mako/template.py, line 292:
as_unicode=True)
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/templating.py, line 240:
return literal(template.render_unicode(**globs))
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/templating.py, line 218:
return render_func()
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/templating.py, line 243:
cache_type=cache_type, cache_expire=cache_expire)
/tomyapp/SimpleSite/simplesite/controllers/page.py, line 25:
return render('/derived/page/new.html')
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/controllers/core.py, line 57:
return func(**args)
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/controllers/core.py, line 105:
result = self._perform_call(func, args)
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/controllers/core.py, line 162:
response = self._inspect_call(func)
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/controllers/core.py, line 211:
response = self._dispatch_call()
/tomyapp/SimpleSite/simplesite/lib/base.py, line 18:
return WSGIController.__call__(self, environ, start_response)
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/wsgiapp.py, line 312:
return controller(environ, start_response)
/tomyapp/mydevenv/lib/python2.5/site-packages/Pylons-1.0-py2.5.egg/
pylons/wsgiapp.py, line 107:
response = self.dispatch(controller, environ, start_response)
/tomyapp/mydevenv/lib/python2.5/site-packages/Routes-1.12.3-py2.5.egg/
routes/middleware.py, line 131:
response = self.app(environ, start_response)
/tomyapp/mydevenv/lib/python2.5/site-packages/Beaker-1.5.4-py2.5.egg/
beaker/middleware.py, line 152:
return self.wrap_app(environ, session_start_response)
/tomyapp/mydevenv/lib/python2.5/site-packages/WebError-0.10.3-
py2.5.egg/weberror/evalexception.py, line 431:
app_iter = self.application(environ, detect_start_response)


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to