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?
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---