Monorail and Brail: how to access siteRoot in a common script?

23 views
Skip to first unread message

Gabriel Schenker

unread,
Oct 1, 2008, 4:44:28 AM10/1/08
to Castle Project Users
I try to write a common script in brail and want to access the
siteRoot parameter.
But the compiler tells me, that it is not found...

my definition of the script is

def statusImage(status, title):
return "<img src='${siteRoot}/images/status_${status}.png' alt='$
{title}' title='${title}' />"
end

the exception is:

Exception Details: Castle.MonoRail.Framework.MonoRailException:
CommonScripts\statusImage.brail(1,1): BCE0005:
Boo.Lang.Compiler.CompilerError: Unknown identifier: 'siteRoot'.

Ayende Rahien

unread,
Oct 1, 2008, 5:15:37 AM10/1/08
to castle-pro...@googlegroups.com
You can't, unfortunately.
Common Scripts are just plain boo files, no brail magic.
You can access that from the HttpContext, I assume.

Gabriel Schenker

unread,
Oct 2, 2008, 3:42:33 AM10/2/08
to castle-pro...@googlegroups.com
ok, I try this one (copied from Castle C# code...)

import System.Web
 
def applicationPath():
  path = HttpContext.Current.Request.ApplicationPath
  if "/".Equals(path):
    path = string.Empty;
  end
  return path
end

// some more code here...

but I get the following error now:


Exception Details: Castle.MonoRail.Framework.MonoRailException: CommonScripts\statusImage.brail(1,1): BCE0005: Boo.Lang.Compiler.CompilerError: Unknown identifier: 'HttpContext'.

interestingly I have no problems with other namespaces and/or classes of the .NET framework, e.g. System.Threading.Thread

what am I missing?

Ayende Rahien

unread,
Oct 2, 2008, 3:47:39 AM10/2/08
to castle-pro...@googlegroups.com
import System.Web from System.Web

Gabriel Schenker

unread,
Oct 2, 2008, 3:50:56 AM10/2/08
to castle-pro...@googlegroups.com
that was quick! thanks. It works now.
But just a question: when do I have to add the "from" to the import statement and when not
Is e.g. the mscorlib.dll automatically recognized and all others not?

Ken Egozi

unread,
Oct 2, 2008, 3:57:36 AM10/2/08
to castle-pro...@googlegroups.com
I believe it's a matter of references.

by default the boo compiler references mscorlib for every compilation, while System.Web.dll is optional.
Same as in csc and vbc

Gabriel Schenker

unread,
Oct 2, 2008, 4:02:10 AM10/2/08
to castle-pro...@googlegroups.com
that makes sense.

Ayende Rahien

unread,
Oct 2, 2008, 1:19:40 PM10/2/08
to castle-pro...@googlegroups.com
More than that, if the namespace cannot be found the boo compiler will look for an assembly with the same name.
So:
import foo.bar.baz

Will look for assemblies named:
foo.bar.baz
foo.bar
foo

Before giving up.
The problem is that mscorlib already contains System.Web

Ken Egozi

unread,
Oct 2, 2008, 1:23:00 PM10/2/08
to castle-pro...@googlegroups.com
what about:
booc.exe input.boo /eagerimport

eagerimport => always try to load references (from the current directory) even if the namespace already exists

Ayende Rahien

unread,
Oct 2, 2008, 1:39:25 PM10/2/08
to castle-pro...@googlegroups.com
Um,
You are aware that I am not actually a member of the Boo, I am just a lowly user.

Ken Egozi

unread,
Oct 2, 2008, 1:50:48 PM10/2/08
to castle-pro...@googlegroups.com
I know.
I also know an actual proposal should be pointed to the boo community, not to Castle.
Reply all
Reply to author
Forward
0 new messages