Hi Alessandro,
You're right, I guess I wasn't clear explaining my problem. When my
Angular2 app uses HashLocationStrategy the request doesn't get to TG, but,
neither does Google bots, url's like
/catalog#/category/443435523daf321f123123sfaf1234
get ignore past the '#'
So I needed to change to the new routing strategy, which doesn't use hash
anymore. Then TG was trying to assign a controller to the URL being asked
by the browser.
I was fool thinking that I needed to return a static file, when in fact I
needed to return nothing. So in a moment of pure inspiration, =), I did
exactly that, returned 'nothing' but an empty dict.
class CatalogController(BaseController):
# Uncomment this line if your controller requires an authenticated user
# allow_only = predicates.not_anonymous()
@expose('bodegagourmet.templates.catalog')
def _default(self, *args):
return dict()
@expose('bodegagourmet.templates.catalog')
def index(self, **kw):
return dict(page='catalog-index')
Success, my app now works wonderful with TG as backend.
Thank you Alessandro
On Thursday, September 1, 2016 at 2:19:11 AM UTC-5, Alessandro Molina wrote:
>
> I think I didn't understand which exactly is the problem, you mentioned
> three different things :D
>
> - If your URLS are all like /catalog#/category/443435523daf321f123123sfaf1234
> the only endpoint TG will see is /catalog so they should all be served by
> index. So how can it be returning 404?
> - Do you have an example that I can download to reproduce the problem?
> - If you need to return static content anything you put into the "public"
> directory of your app will be directly available, usually the only reason
> to roll your own static serving is for pluggable/reusable components as
> those are not inside the same app that user will run.
>
> Regarding how to tell TG to "ignore requests" can you explain what you
> mean by "ignoring"? If TG receives a request it's because the browser sent
> it to the server, so at that point the server must return some kind of
> response. What kind of response do you expect to return? As we are talking
> of a SPA I suppose what you mean for ignoring is that it should be managed
> by angular and not TG, which means that your browser shouldn't be sending
> any request as Angular should have trapped it and never let it reach the
> server.
>
> I'm not an angular guy but If you can try to provide an example that
> showcases the actual situation and problem I'll gladly try help you :D
>
> On Wed, Aug 31, 2016 at 7:09 PM, Juparave <[email protected] <javascript:>>
> wrote:
>
>> I'm developing a simple online catalog using Turbogears as backend to an
>> Angular app.
>>
>> The structure is very simple, you can look at my seed project
>> https://bitbucket.org/juparave/turboangular
>>
>> The app runs very smooth and well. But, it has come to my attention
>> that, using Angular's HashLocationStrategy google is unable to parse
>> content.
>>
>> My design uses a catalog_controller.py which only renders index, from
>> there Angular takes over, having urls like
>> '/catalog#/category/443435523daf321f123123sfaf1234'
>>
>>
>> class CatalogController(BaseController):
>> # Uncomment this line if your controller requires an authenticated user
>> # allow_only = predicates.not_anonymous()
>>
>> @expose()
>> def _default(self, *args):
>> site_dir = os.path.join(config.get('here'), '/catalogapp/public')
>>
>> return StaticURLParser(site_dir)(tg.request)
>> # return WSGIAppController(StaticURLParser(site_dir)), args
>>
>> @expose('bodegagourmet.templates.catalog')
>> def index(self, **kw):
>> return dict(page='catalog-index')
>>
>>
>>
>> I'm trying to use the new Angular routing systems which no longer
>> requires hashes, but now all those links are intercepted by TG controllers,
>> returning 404's everywhere.
>>
>> I also tried returning static content using the example in this post
>> https://groups.google.com/forum/#!topic/turbogears/OPFJVLpGi6s but also
>> returns 404.
>>
>> My question is, where to tell TG to ignore requests beyond a controller?
>>
>> I mean, I'm looking for TG to ignore all requests from /catalog/ (except,
>> maybe for index)
>>
>> Thanks
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "TurboGears" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/turbogears.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.