def show_body(self, actor): # XXX the env should be a sprout of the actor's env # shared by its other examples # XXX skip result if actor is None if actor not in self.results: self._add_result(actor, self._run(actor)) result = self.results[actor] if type(result) == type(''): result_html = html.escape(result) else: # XXX we don't necessarily have editor privileges on the result result_html = '<a href="%s">%s</a>' % (get_uri( get_editor(result)), result.link_caption()) return '? %s<br>%s' % (self.expression.mark_up( actor.get_env()), result_html)
def show_body(self, actor): # XXX the env should be a sprout of the actor's env # shared by its other examples # XXX skip result if actor is None if actor not in self.results: self._add_result(actor, self._run(actor)) result = self.results[actor] if type(result) == type(''): result_html = cgi.escape(result) else: # XXX we don't necessarily have editor privileges on the result result_html = '<a href="%s">%s</a>' % (get_uri(get_editor(result)), result.link_caption()) return '? %s<br>%s' % (self.expression.mark_up(actor.get_env()), result_html)
def make_account(): from actors import Expression # XXX circular module dependency root_env = global_env.sprout() sender_script = \ Script([Method('send:', ['message'], 'inbox <- ([message] + inbox get)')]) mailbox_script = \ Script([Method('first', [], 'inbox get at: 1'), Method('removefirst', [], 'inbox <- (inbox get from: 2)'), Method('sender', [], 'sender')]) makemailbox_run = \ Method('run', [], Expression('let inbox = makebox holding: []. make sender. make mailbox', {'sender': sender_script, 'mailbox': mailbox_script})) root_env.define('makemailbox', Actor(root_env, Script([makemailbox_run]))) root_env.define('maildirectory', maildir_actor) root_actor = \ Actor(root_env, Script([Text('Welcome to your new account. You should bookmark this page if you ever intend to return, because going back and clicking "Go!" again would create another new account with a different URI.\n\nIn Hmph, everything is an object, and every object has a page with a generated URI. For example, the number 2 is an object. Below, we send it the message "+ 3" and it adds 3 to itself, yielding 5:'), Example('2 + 3'), Example('(3*3) + (4*4)'), Text('The syntax is related to Smalltalk, but not the same. To make a new type of object, decide on what to call it in the local scope, such as Foo, and enter "make Foo":'), Example('make Foo'), Text('You can also give a local name to any other object using "let name = expression". For example:'), Example('let box = makebox holding: true'), Example('box get'), Example('box <- false. box get'), Example("['hello']"), Text("""There's a public directory of message boxes for other users, in maildirectory:"""), Example('maildirectory'), Text('You can create your own mailbox:'), Example('let mailbox = makemailbox run'), Text("""To add it to the directory, enter "maildirectory at: 'alice' put: mailbox sender" into the "Add example" field below, changing alice to some single-word identifier of your choice. (This will fail and return false if that identifier is already taken.) Then inspect "mailbox" to see how to get your messages. A message can be any object, not just plain text."""), Text("""Have fun exploring! Don't put much work into it, at least yet, because this account *will* get zapped during code upgrades; I'm not ready to commit to continuity yet. There will be actual documentation real soon now. Please send feedback to Darius Bacon <*****@*****.**>. Thanks!""") ])) return get_editor(root_actor)
def format_variable(string, env, inner_map): value = env.get(string) if value is not None: return '<a href="/id/%s">%s</a>' % (get_id(get_editor(value)), string) return string
def show(self): to_editor = '<a href="%s">[Unseal]</a><hr>' % get_uri(get_editor(self)) return to_editor + self.show_data() + self.get_script().show_bare(self)
def call(self, selector, arguments): # XXX This should only *try* to get an editor view on the # result, using a can-opener capability. Might not succeed. return get_editor(self.actor.call(selector, arguments))