[Seaside] How do I get the base URL? I want to send out an email
with a link
sean at monkeysnatchbanana.com
Thu Aug 5 20:36:53 UTC 2010
as far as i know, there is no way to get the complete url w/ domain,
you have to build it yourself from
the information you can get from request like what you are doing.
On Thu, Aug 5, 2010 at 4:01 PM, Pat Maddox <patmaddox at me.com> wrote:
> requestContext request url doesn't return the full URL for me. Here's what I ended up doing:
> | url request |
> applicationUrl ifNil: [
> request := self requestContext request.
> url := request url withoutQuery.
> (self application url relativeTo: url) do: [ :each |
> url path removeLast ].
> applicationUrl := 'http://' , request host , url asString ].
> ^ applicationUrl.
> Then my WAComponent subclass just delegates to 'session applicationUrl'.
> I have some objects that aren't WAObject descendants at all, so I made a WAObject subclass called ARPApplicationConfig, which I added applicationUrl as a class method to, and then it uses the singleton pattern to create a new instance and delegate applicationUrl to that instance. So in my other objects that need access to the URL, I can just call 'ARPApplicationConfig applicationUrl'.
> Thanks everyone for the input. I'll report back if I run into any problems with it.
> On Aug 4, 2010, at 10:00 PM, Philippe Marschall wrote:
>> 2010/8/4 Pat Maddox <patmaddox at me.com>:
>>> Okay so the high level goal is to send out an email that contains a link to my application. Think http://myapplication.com/invite/abc123
>>> I'm not sure how to go about doing this. I found WAApplication#url which sent me on an interesting journey...because when I did "self halt" inside of a WAComponent subclass and ran "self application" then I get a WARequestContextNotFound error, although apparently that's only when I launch a debugger.
>>> So after figuring out that I can't access "self application" from the debugger I finally got "self application url" rendered on my page, and saw that it was only the path. How can I get the full URL? I don't want to hardcode it...I assume I should be able to get the base URL of my application from somewhere but I'm not sure.
>> Try something like this:
>> | url |
>> url := self requestContext request url withoutQuery.
>> (self application url relativeTo: url) do: [ :each |
>> url path removeLast ].
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
> seaside mailing list
> seaside at lists.squeakfoundation.org
More information about the seaside