Найти - Пользователи
Полная версия: Создать контролер на лету
Начало » Pyramid / Pylons / TurboGears » Создать контролер на лету
1
PooH
А вот можно ли сделать примерно так

class ParentController:

@expose()
def default(self, id):
child = ChildController(id)
#а здесь как нибудь продолжить разбор пути в созданном контролере


???
pythonwin
можно :)
можно даже создавать контролеры из описаний в БД, но это сильно усложнит поиск ошибок
PooH
pythonwin
можно :)
Лаконично ;)
собственно интересовало, как продолжить траверсинг урла по созданному контролеру
pythonwin
http://localhost:8080/?children=
from turbogears import controllers, expose
class ChildRoot(controllers.RootController):
def __init__(self, k='', **kw):
self.k = k
@expose(template=“test_dinamic.templates.welcome”)
def index(self, id=1, **kw):
import time
return dict(now=time.ctime())

class Root(controllers.RootController):
@expose(template=“test_dinamic.templates.welcome”)
def index(self, children = ):
children = eval(children)
for k in children:
if not getattr(self, k, False):
setattr(self, k, ChildRoot(k))
print
import time
return dict(now=time.ctime())
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB