public static function wrap($object, $class = 'ViewableWrapper', $add_init_code=true)
    {
        if (self::is_publishing()) {
            $class2 = "{$class}_LivePub";
            if (class_exists($class2, true)) {
                $class = $class2;
            }

            $obj = new $class($object);
            if ($add_init_code && ($init = $obj->getStaticInit())) {
                self::$init_code[] = $init;
            }
        } else {
            $obj = new $class($object);
        }

        return $obj;
    }