On Fri, Jul 13, 2012 at 2:34 PM, Alejandro Jatib <aja
...@gmail.com> wrote:
> I forget to say that i was using pyramid_appengine and hosting my app in
> appengine.
> El viernes, 13 de julio de 2012 00:51:02 UTC-3, Alejandro Jatib escribió:
>> Hey folks,
>> I want to use dynamic subdomains as follows:
>> name1.domainapp.com
>> name2.domainapp.com
>> nameX.domainapp.com
>> When someone enters in these directions should be redirected to:
>> domainapp.com/name1
>> domainapp.com/name2
>> domainapp.com/namex
>> I tried several examples I found and I end up doing this:
>> in __init__.py:
>> def pregen(request, elements, kw):
>> #kw['_app_url'] = 'http://www.domainapp.com/' +
>> request.host.split('.')[0]
>> return elements, kw
>> def req_sub(info, request):
>> return request.host.split('.')[0] != 'www'
>> config.add_route('sub_only', '/{id:.*?}',
>> custom_predicates=(req_sub,),
>> #pregenerator=pregen
>> )
>> in views.py:
>> @view_config(route_name='sub_**only')
>> def Subdomain(request):
>> # redirect the user to "http://sub.example.com", regardless of
>> whether
>> # request.host is "example.com" or "sub.example.com"
>> return HTTPFound(location='http://**www.domainapp.com/<http://www.domainapp.com/>'
>> + request.host.split('.')[0])
>> Any suggestions to make it better?
>> Thanks
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/BxECKuWWd_4J.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.