[reportlab-users] cgi-problem with reportlab&attribute error: 'None Type' object has no attribute 'split'

Proboscis Admin reportlab-users@reportlab.com
Thu, 11 Sep 2003 16:25:59 +0100


--Apple-Mail-4--912586092
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Dear Tim,

Thank you very much!!!

as it turned out I hadnt put the exception so when the field was empty 
it raised an error.like you said!

I have a couple more question as I am not experienced in this. could 
you please tell me where do I save my HTML form?in the same file as my 
python program? also the s and q in the code sample you provided does q 
represent the form name & the s what? or are they just variables?
Now using the sample cgi script you suggested, if I wanted to use that 
text that was taken from the HTML to be placed in a certain location in 
the pdf assuming the HTML form has is a textarea I tried this:

q = cgi.FieldStorage()

if q.has_key('Page2'):
	s = q['Page2'].value
else:
		s = None
c.setFillColor(colors.white)
c.rect(111.5*mm,37*mm,85*mm,100*mm, fill = 1)
c.saveState()
story = []
c.translate(111.5*mm,37*mm)
c.rotate(180)
f = Frame(-85*mm, -100*mm, 85*mm,100*mm, showBoundary=0)
styles = getSampleStyleSheet()
styleN = styles['Normal']
story.append(Paragraph((s),styleN))
f.addFromList(story,c)
c.restoreState()

but I am getting an attribute error: 'None Type' object has no 
attribute 'split'

in the file paragraph.py line 376&397&51 also in string.py line 122. 
please advice with code also if you can.

  thank you again.


On Wednesday, September 10, 2003, at 05:54 PM, Tim Roberts wrote:

> On Tue, 9 Sep 2003 12:51:30 +0100, Proboscis Admin 
> <admin@proboscis.org.uk>
> wrote:
>>
>> ive made a tool using reportlab but it requires the text to be 
>> imported
>> from the html form.im using CGI for that but I am getting a key error
>> due to the cgi.py module in python which is raising an exception
>> because it can not get the text.i think the problem is referring the
>> python/reportlab code to the html form does anyone have an idea or
>> advice?
>> I have used the same input names as in the html form.
>
> You will have to be much more specific.  Including snippets of code 
> and the
> exact error message are a must.
>
> However, it is much more likely that you have a cgi problem, not a 
> ReportLab
> problemn.  We might want to redirect this to comp.lang.python.
>
> The cgi.py module can be a bit picky.  Your capitalization must match
> exactly; if the form has:
>    <input type=text name=MyText>
> then you must use
>   q = cgi.FieldStorage()
>   s = q['MyText'].value
>
> Also note that if you do not fill in a field, the field name will not 
> appear
> in the FieldStorage object at all.  That's a common error.  
> Fortunately, it's
> easy to check for that:
>
>   if q.has_key('MyText'):
>     s = q['MyText'].value
>   else:
>     s = None
>
>
> --
> - Tim Roberts, timr@probo.com
>   Providenza & Boekelheide, Inc.
>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users@reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
>
Proboscis
researching, developing and facilitating creative innovation
2 Ormonde Mansions, 100A Southampton Row, London WC1B 4BJ
T:	020 7209 4042			F:  07031 151 738
E:	info@proboscis.org.uk	W: http://www.proboscis.org.uk

--Apple-Mail-4--912586092
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
	charset=US-ASCII

Dear Tim,


Thank you very much!!!


as it turned out I hadnt put the exception so when the field was empty
it raised an error.like you said!


I have a couple more question as I am not experienced in this. could
you please tell me where do I save my HTML form?in the same file as my
python program? also the s and q in the code sample you provided does
q represent the form name & the s what? or are they just variables?

Now using the sample cgi script you suggested, if I wanted to use that
text that was taken from the HTML to be placed in a certain location
in the pdf assuming the HTML form has is a textarea I tried this:


<fontfamily><param>Geneva</param>q = cgi.FieldStorage()


if q.has_key('Page2'):

	s = q['Page2'].value

else:

		s = None</fontfamily>

<fontfamily><param>Geneva</param>c.setFillColor(colors.white)

c.rect(111.5*mm,37*mm,85*mm,100*mm, fill = 1)

c.saveState()

story = []

c.translate(111.5*mm,37*mm)

c.rotate(180)

f = Frame(-85*mm, -100*mm, 85*mm,100*mm, showBoundary=0)

styles = getSampleStyleSheet()

styleN = styles['Normal']

story.append(Paragraph((s),styleN))

f.addFromList(story,c)

c.restoreState()</fontfamily>


but I am getting an attribute error: 'None Type' object has no
attribute 'split'


in the file paragraph.py line 376&397&51 also in string.py line 122.
please advice with code also if you can.


 thank you again.



On Wednesday, September 10, 2003, at 05:54 PM, Tim Roberts wrote:


<excerpt>On Tue, 9 Sep 2003 12:51:30 +0100, Proboscis Admin
<<admin@proboscis.org.uk> 

wrote:

<excerpt>

ive made a tool using reportlab but it requires the text to be
imported 

from the html form.im using CGI for that but I am getting a key error 

due to the cgi.py module in python which is raising an exception 

because it can not get the text.i think the problem is referring the 

python/reportlab code to the html form does anyone have an idea or 

advice?

I have used the same input names as in the html form.

</excerpt>

You will have to be much more specific.  Including snippets of code
and the 

exact error message are a must.


However, it is much more likely that you have a cgi problem, not a
ReportLab 

problemn.  We might want to redirect this to comp.lang.python.


The cgi.py module can be a bit picky.  Your capitalization must match 

exactly; if the form has:

   <<input type=text name=MyText>

then you must use

  q = cgi.FieldStorage()

  s = q['MyText'].value


Also note that if you do not fill in a field, the field name will not
appear 

in the FieldStorage object at all.  That's a common error. 
Fortunately, it's 

easy to check for that:


  if q.has_key('MyText'):

    s = q['MyText'].value

  else:

    s = None



--

- Tim Roberts, timr@probo.com

  Providenza & Boekelheide, Inc.



_______________________________________________

reportlab-users mailing list

reportlab-users@reportlab.com

http://two.pairlist.net/mailman/listinfo/reportlab-users



</excerpt>Proboscis

researching, developing and facilitating creative innovation

2 Ormonde Mansions, 100A Southampton Row, London WC1B 4BJ

T:	020 7209 4042			F:  07031 151 738

E:	info@proboscis.org.uk	W: http://www.proboscis.org.uk


--Apple-Mail-4--912586092--