[Zope-CMF] Re: [ZPT] Content-type on PageTemplateFile

Thomas Olsen tol@tanghus.dk
Sat, 26 Jan 2002 22:39:03 +0100


--------------Boundary-00=_3TEKMIDNCH7B6YZZ7RVD
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Hi again

Guess I'd better put some action to my ideas :-)

I have hacked CMFCore/FSPageTemplate.py to achieve what I mentioned below. 
Using this hack you can add a header to a FSPageTemplate looking like e.g.:

---[snip]--------------------------------
<!-- Page Template Configuration
## PageTemplate "SMIL.smil"
##attributes=content_type=application/smil
##title=SMIL generator
-->
<smil>
<!-- blah blah -->
</smil>
---[snip]--------------------------------

Maybe it would be an idea to limit what attributes you can set or maybe 
change the syntax to something like:

<!-- Page Template Configuration
## PageTemplate "SMIL.smil"
##content-type==application/smil
##expand=TTW=0,DAV=1
##title=SMIL generator
-->

A diff is attached if it is of any interest. Now I better get back to the job 
I'm getting paid to do :-)

On Saturday 26 January 2002 07:24, Thomas Olsen wrote:
> Oh yes - me being stupid ;-)
>
> Actually what I was thinking but didn't mention was something like
> filesystem python scripts:
>
> <!--
> ## PageTemplate "my_template"
> ##attributes=content_type=text/plain,expand=0
> ##title=My Template
> -->
>
> Just a thought...
>
> On Friday 25 January 2002 16:54, Evan Simpson wrote:
> > Thomas Olsen wrote:
> > > Is it in anyway possible programmatically to set the 'content_type' on
> > > a PageTemplateFile?
> >
> > Sure.  In the Python code that creates the PTF, do like so:
> >
> > myptf = PageTemplateFile(...)
> > myptf.content_type = 'text/funky'
> >
> > Cheers,
> >
> > Evan @ Zope
> >
> >
> >
> > _______________________________________________
> > ZPT mailing list
> > ZPT@zope.org
> > http://lists.zope.org/mailman/listinfo/zpt

-- 
Regards
Thomas Olsen

http://www.tanghus.dk
--------------Boundary-00=_3TEKMIDNCH7B6YZZ7RVD
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="FSPageTemplate.diff"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="FSPageTemplate.diff"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iAgICAgICAgIHNlbGYuX3VwZGF0ZUZyb21GUygpCiAgICAgICAgIHJldHVybiBGU1BhZ2VUZW1w
bGF0ZS5pbmhlcml0ZWRBdHRyaWJ1dGUoJ3JlYWQnKShzZWxmKQogCisgICAgIyMjIFRoZSBmb2xs
b3dpbmcgaXMgbWFpbmx5IHRha2VuIGZyb20gUHl0aG9uU2NyaXB0LnB5ICMjIworICAgIHNlY3Vy
aXR5LmRlY2xhcmVQcml2YXRlKCd3cml0ZScpCisgICAgZGVmIHdyaXRlKHNlbGYsIHRleHQpOgor
ICAgICAgICBpZiB0ZXh0WzpsZW4oc2VsZi5fY29uZmlnX3N0YXJ0KV0gPT0gc2VsZi5fY29uZmln
X3N0YXJ0OgorICAgICAgICAgICAgI0xPRyhzZWxmLm1ldGFfdHlwZSwgSU5GTywgJ3dyaXRlKCkn
LCAnRm91bmQgYSBoZWFkZXInKQorICAgICAgICAgICAgY29uZmlnZW5kID0gZmluZCh0ZXh0LCAn
LS0+JykKKyAgICAgICAgICAgIGlmIGNvbmZpZ2VuZCA+PSAwOgorICAgICAgICAgICAgICAgIG1h
cmt1cCA9IHRleHRbY29uZmlnZW5kICsgNDpdCisgICAgICAgICAgICAgICAgY29uZmlnID0gdGV4
dFtsZW4oc2VsZi5fY29uZmlnX3N0YXJ0KTpjb25maWdlbmRdCisgICAgICAgICAgICAgICAgI0xP
RyhzZWxmLm1ldGFfdHlwZSwgSU5GTywgJ3dyaXRlKCknLCAnQ29uZmlnOiAlcycgJSBjb25maWcp
CisgICAgICAgICAgICAgICAgc3QgPSAwCisgICAgICAgICAgICAgICAgdHJ5OgorICAgICAgICAg
ICAgICAgICAgICB3aGlsZSAxOgorICAgICAgICAgICAgICAgICAgICAgICAgIyBGaW5kIHRoZSBu
ZXh0IG5vbi1lbXB0eSBsaW5lCisgICAgICAgICAgICAgICAgICAgICAgICBtID0gX25vbmVtcHR5
X2xpbmUuc2VhcmNoKGNvbmZpZywgc3QpCisgICAgICAgICAgICAgICAgICAgICAgICBpZiBub3Qg
bToKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAjIFRoZXJlIHdlcmUgbm8gbm9uLWVtcHR5
IGJvZHkgbGluZXMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaworICAgICAgICAg
ICAgICAgICAgICAgICAgbGluZSA9IG0uZ3JvdXAoMCkuc3RyaXAoKQorICAgICAgICAgICAgICAg
ICAgICAgICAgaWYgbGluZVs6Ml0gIT0gJyMjJzoKKyAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAjIFdlIGhhdmUgY29tZSB0byB0aGUgZW5kIG9mIHRoZSBjb25maWcgc2VjdGlvbgorICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIGJyZWFrCisKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0
ID0gbS5lbmQoMCkKKyAgICAgICAgICAgICAgICAgICAgICAgICMgUGFyc2UgdGhpcyBoZWFkZXIg
bGluZQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgbGVuKGxpbmUpID09IDIgb3IgbGluZVsy
XSA9PSAnICcgb3IgJz0nIG5vdCBpbiBsaW5lOgorICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICMgTnVsbCBoZWFkZXIgbGluZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVl
CisgICAgICAgICAgICAgICAgICAgICAgICBrLCB2ID0gbGluZVsyOl0uc3BsaXQoJz0nLCAxKQor
ICAgICAgICAgICAgICAgICAgICAgICAgayA9IGsuc3RyaXAoKS5sb3dlcigpCisgICAgICAgICAg
ICAgICAgICAgICAgICB2ID0gdi5zdHJpcCgpCisKKyAgICAgICAgICAgICAgICAgICAgICAgICNM
T0coc2VsZi5tZXRhX3R5cGUsIElORk8sICdtZXRhIGRhdGEnLCAnJXM6ICVzJyAlIChrLCB2KSkK
KyAgICAgICAgICAgICAgICAgICAgICAgICMgU2V0IG1ldGFkYXRhIHZhbHVlCisgICAgICAgICAg
ICAgICAgICAgICAgICBpZiBrID09ICd0aXRsZSc6CisgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgc2VsZi50aXRsZSA9IHYKKyAgICAgICAgICAgICAgICAgICAgICAgIGVsaWYgayA9PSAnYXR0
cmlidXRlcyc6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fYXR0cmlidXRlcyA9
IHYKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWlycyA9IHNwbGl0KHYsICcsJykKKyAg
ICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgcGFpciBpbiBwYWlyczoKKyAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAga2V5LCB2YWx1ZSA9IHNwbGl0KHBhaXIsICc9JykKKyAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fX2RpY3RfX1trZXldID0gdmFsdWUKKwor
ICAgICAgICAgICAgICAgIGV4Y2VwdDoKKyAgICAgICAgICAgICAgICAgICAgTE9HKHNlbGYubWV0
YV90eXBlLCBFUlJPUiwgJ3dyaXRlIGZhaWxlZCcsIGVycm9yPXN5cy5leGNfaW5mbygpKQorICAg
ICAgICAgICAgICAgICAgICByYWlzZQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgbWFya3Vw
ID0gdGV4dAorICAgICAgICBzZWxmLl90ZXh0ID0gbWFya3VwCisgICAgICAgIEZTUGFnZVRlbXBs
YXRlLmluaGVyaXRlZEF0dHJpYnV0ZSgnd3JpdGUnKShzZWxmLCBtYXJrdXApCisKICAgICAjIyMg
VGhlIGZvbGxvd2luZyBpcyBtYWlubHkgdGFrZW4gZnJvbSBab3BlUGFnZVRlbXBsYXRlLnB5ICMj
IwogCiAgICAgZXhwYW5kID0gMApAQCAtMTIyLDYgKzE3Nyw4IEBACiAgICAgZ2V0U2l6ZSA9IGdl
dF9zaXplCiAgICAgUHJpbmNpcGlhU2VhcmNoU291cmNlID0gWm9wZVBhZ2VUZW1wbGF0ZS5Qcmlu
Y2lwaWFTZWFyY2hTb3VyY2UKICAgICBkb2N1bWVudF9zcmMgPSBab3BlUGFnZVRlbXBsYXRlLmRv
Y3VtZW50X3NyYworCitfbm9uZW1wdHlfbGluZSA9IHJlLmNvbXBpbGUoJyg/bSleKC4qXFMuKikk
JykKIAogCiBkID0gRlNQYWdlVGVtcGxhdGUuX19kaWN0X18K

--------------Boundary-00=_3TEKMIDNCH7B6YZZ7RVD--

_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature requests