article.py 751 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:origin.py
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class view_path(Load):
  10. @Web.setting
  11. def get(self):
  12. id = self.input('id')
  13. if not id:
  14. self.out('error')
  15. return
  16. self.data['info'] = self.service('common').one('web_article', id=id)
  17. self.view("view.html")
  18. class index_path(Load):
  19. @Web.setting
  20. def get(self):
  21. search = {}
  22. search['category_id'] = 2
  23. self.data['list'] = self.service('common').list('web_article', search=search, page={'num':10})
  24. if self.data['list']:
  25. for key, value in enumerate(self.data['list']):
  26. self.data['list'][key]['link'] = '/article/view?id=' + str(value['id'])
  27. self.view("list.html")