2008/10/3 Garito <[EMAIL PROTECTED]>:
>
> This could be perfect for my needs but I can't use read_mime_types
> without problems
>
> If I put
>
> from mimetypes import read_mime_types, add_type
> add_type('text/yanged-page-template', 'ypt')
>
>
> read_mime_types(self._url)
>
> where self._url is the absolute path to the file
>
> it returns the whole list of mime types not the file one
>
> Could you see where is the problem?

You've lost me again on what you are trying to do. Why would you want
to read in mime types from file based on the URL of a request? A URL
is a logical thing and wouldn't necessarily correspond to physical
file.

You still need to use guess_type() as you were, but you are just using
read_mime_types() to populate internal Python mime types table with
additional entries from static unchanging file. This populating of
table would be done only once at global scope. But then, would only
use read_mime_types() if really wanted to populate with multiple
entries. If only a few just use add_type().

You probably need to provide full code for small self contained
example rather than just posting a single line snippet without
context.

Graham

> Thanks!
>
> On 3 oct, 14:52, "Graham Dumpleton" <[EMAIL PROTECTED]>
> wrote:
>> 2008/10/3 Garito <[EMAIL PROTECTED]>:
>>
>>
>>
>> > Hi Graham!
>> > I go to /etc/mime.types and I add
>>
>> > text/yanged-page-template  ypt
>>
>> > Then in my wsgi module I use guess_type python function to determine
>> > the mime type of an object and all goes as expected
>>
>> > But if I delete this mime type from /etc/mime.types and add it to my
>> > site configuration via AddType it doesn't work as expected
>>
>> > Did you know how to do that or where is my mistake?
>>
>> Table that guess_type() uses is Python interpreter global.
>>
>> AddType directive in Apache is internal Apache and can also apply to
>> specific URL context only. Since many URL contexts may map to single
>> Python interpreter, couldn't merge AddType stuff into Python data
>> structure.
>>
>> If however you know your application is only thing running in Python
>> interpreter instance, you can just extend table used by guess_type().
>> Ie:
>>
>>   import mimetypes
>>   mimetypes.add_type('text/yanged-page-template','ypt')
>>
>> Think you can also load a whole file of such information. Ie.,
>>
>>   mimetypes.read_mime_types(filename)
>>
>> Do this at global scope of code file so it is add when first loaded.
>>
>> See Python module documentation.
>>
>> Graham
>>
>> > Thanks a lot!
>>
>> > On 3 oct, 13:47, "Graham Dumpleton" <[EMAIL PROTECTED]>
>> > wrote:
>> >> 2008/10/3 Graham Dumpleton <[EMAIL PROTECTED]>:
>>
>> >> > 2008/10/3 Garito <[EMAIL PROTECTED]>:
>>
>> >> >> Hi!
>> >> >> Is there any way to do that mod_wsgi use apache mime types?
>>
>> >> >> If you go to /etc/mime.types and add some mime types mod_wsgi works ok
>> >> >> with them but if you add them as apache configuration via AddType it
>> >> >> doesn't work
>>
>> >> >> One of my main goals (as you could deduce) is to put the mod_wsgi
>> >> >> configuration as close to .htaccess as I can
>>
>> >> >> Why? Easy:
>>
>> >> >> because if we could put all our configuration in .htaccess we could
>> >> >> use cheap hosting with the only need was to have mod_wsgi active with
>> >> >> full control of it (there are not so much hostings that give you the
>> >> >> change to change /etc/mime.types
>>
>> >> >> Is there a good approach? Do you like this way?
>>
>> >> > Sorry, I don't understand the problem. Can you provide actual examples
>> >> > of what you want to be able to do in Apache configuration?
>>
>> >> > Also explain why you have to use mime types in the first place, why
>> >> > can't it be based on resource extension? Ie.,
>>
>> >> >  AddHandler wsgi_script .wsgi
>>
>> >> Whoops.
>>
>> >>   AddHandler wsgi-script .wsgi
>>
>> >> Graham
>>
>> >> > Thus if resource match to .wsgi, then that resource file is
>> >> > interpreted by mod_wsgi.
>>
>> >> > Graham
> >
>

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

Reply via email to