Re: How to force the content-type of each response?

Philip Semanchuk <[email protected]> Thu, 26 Apr 2007 18:10:08 -0400
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
On Apr 26, 2007, at 6:00 PM, Jonathan Ellis wrote:

> On Thu, 26 Apr 2007 17:49:06 -0400, "Philip Semanchuk"
> <[email protected]> said:
>> So now I have a working module called HeaderModule.py. It looks like
>> this:
>>
>> import spyceModule
>> import time
>>
>> class HeaderModule(spyceModule.spyceModulePlus):
>>      def start(self):
>>          self.modules.response.setContentType("text/html;  
>> charset=utf-8")
>>          file("/tmp/ResponseStart.txt", "w").write(time.asctime())
>>
>> When I add [[.import name= HeaderModule]] to the top of a .spy file,  
>> my
>> content-type header gets sent and the timestamp in the /tmp file is
>> updated, so I know that the module works.
>>
>> I still can't get it to work automatically, though. You mentioned a
>> globalmodules option and I can't find reference to that anywhere in  
>> the
>> code or documentation. Adding HeaderModule to the globals in
>> spyceconf.py doesn't seem to do the trick. What am I missing?
>
> you updated to the latest 2.2 branch?

Aha, I'm still on r1353, not 1354. Didn't realize that this feature was  
present only in the latest rev. And here I was hoping to figure out how  
to make this solution work in 2.0.3.  :-D

OK, for now I'll just modify my Spyce files with a custom tag. That  
won't be too hard. And in the meantime I'll keep poking at 2.2. This  
gives me another incentive to upgrade.

Thanks for your time
Philip



>
> there should be a line in spyceconf.py that says
> globalmodules = []
>
> so in your config.py you can write
> globalmodules.append('HeaderModule')
>
> ----------------------------------------------------------------------- 
> --
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Spyce-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spyce-users
>


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/