Hello,
I get these error messages:
Default renderer not in renders, automatically switching to json
app_globals not provided and lib.app_globals.Globals is not available.
The docs say Minimal is supposed to provide these. I am in minimal mode,
just a single file.
Am I supposed to be able to refer to tg.request.validation out of the box?
Thank you! (I looked at bottle, flask and mojolicious, I would like to
work with TG2 I just like it better...)
for example here's the whole thing:
from tg import RestController
from formencode import validators
from mahjong.hand_calculating.hand import HandCalculator
from mahjong.tile import TilesConverter
from mahjong.hand_calculating.hand_config import HandConfig
from mahjong.meld import Meld
# RootController of our web app, in charge of serving content for /
class RootController(RestController):
@expose('json')
@validate({"man":validators.String(not_empty=True),
"pin":validators.String(not_empty=True),
"sou":validators.String(not_empty=True),
"win":validators.String(not_empty=True)})
def calc(self, man, pin, sou, **kw):
# validation_status = tg.request.validation
# errors = [{key, value} in validation_status.errors.iteritems()]
# values = validation_status.values
calculator = HandCalculator()
# tiles = TilesConverter.string_to_136_array(man='22444',
pin='333567', sou='444')
tiles = TilesConverter.string_to_136_array(man=man, pin=pin,
sou=sou)
win_tile = TilesConverter.string_to_136_array(sou=sou)[0]
result = calculator.estimate_hand_value(tiles, win_tile)
# return dict(han=result.han, fu=result.fu, errors=str(errors),
values=str(values))
return dict(han=result.han, fu=result.fu)
# Configure a new minimal application with our root controller.
config = MinimalApplicationConfigurator()
config.update_blueprint({
'root_controller': RootController()
})
# Serve the newly configured web application.
print("Serving on port 8080...")
httpd = make_server('', 8080, config.make_wsgi_app())
httpd.serve_forever()
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/turbogears/3b177380-f3fd-43a2-8be7-59712f5146c6%40googlegroups.com.