Esempio n. 1
0
File: top.go Progetto: Laller/nocrud
func (t *Top) Get(ret []interface{}, files []string) error {
	ran := verbinfo.NewRanalyzer(ret)
	if ran.HadError() {
		return display.New(t.ctx).Error(ran.Error())
	}
	burnResults(t.ctx.ViewContext(), "main", ran.NonErrors())
	return display.New(t.ctx).Do(files)
}
Esempio n. 2
0
File: top.go Progetto: Laller/nocrud
func (t *Top) route() (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf(fmt.Sprint(r) + string(debug.Stack()))
		}
	}()
	ctx := t.ctx
	odoc := ctx.Options().Document()
	nouns := scut.GetNouns(odoc)
	np := ctx.NonPortable()
	hl, err := highlev.New(ctx.Conducting().Hooks(), np.Resource(), nouns, np.Params())
	if err != nil {
		display.New(ctx).Do(nil)
		return nil
	}
	deflev_i, _ := odoc.Get("default_level")
	deflev, _ := numcon.Int(deflev_i)
	ret, err := hl.Run(ctx.Db(), ctx.User(), deflev)
	if err != nil {
		return err
	}
	if ctx.NonPortable().View() {
		ctx.ViewContext().Publish("main_noun", hl.Noun())
		files := []string{
			hl.Noun() + "/" + hl.Verb(),
			hl.VerbLocation() + "/" + hl.Verb(),
		}
		return t.Get(ret, files)
	} else {
		return t.Post(ret, hl.Verb())
	}
	return nil
}