Changeset 3571 for waeup/branches
- Timestamp:
- 14 Jul 2008, 21:36:49 (16 years ago)
- Location:
- waeup/branches/hraban/src/waeup
- Files:
-
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/hraban/src/waeup/app.py
r3566 r3571 2 2 #from zope.interface import Interface 3 3 from waeup.interfaces import IUniversity 4 from setup import app_setup5 4 from waeup.viewlets import MainArea 6 5 from basecontainer import BaseContainer 6 from waeup.hostel import hostelcontainer 7 from waeup.university import facultycontainer 8 from waeup.students import studentcontainer 7 9 8 10 class University(grok.Application, BaseContainer): 9 11 grok.implements(IUniversity) 12 id = 'base' 13 name = u'University' 10 14 11 15 def __init__(self, **kw): 12 16 super(University, self).__init__(**kw) 13 17 self.__dict__.update(kw) 14 app_setup.setup(self) 18 19 sc = studentcontainer.StudentContainer() 20 self["students"] = sc 21 22 hc = hostelcontainer.HostelContainer() 23 self["hostels"] = hc 24 25 fc = facultycontainer.FacultyContainer() 26 self["faculties"] = fc 15 27 16 28 #class Content(grok.Viewlet): -
waeup/branches/hraban/src/waeup/basecontainer.py
r3566 r3571 1 # -*- coding: utf-8 -*- 1 2 import grok 2 3 import os … … 10 11 base methods attached to it 11 12 """ 12 grok.implements(IBaseContainer)13 id = 'base'14 name = u"BaseContainer"13 #grok.implements(IBaseContainer) 14 #id = 'base' 15 #name = u"BaseContainer" 15 16 childClass = None 16 17 specialActions = [] … … 31 32 template = grok.PageTemplate(filename=os.path.join('basecontainer_templates', 'edit_form.pt')) 32 33 33 def update(self): 34 def __init__(self, context, request): 35 super(AddForm, self).__init__(context, request) 34 36 self.form_fields = grok.AutoFields(self.context.childClass) 35 grok.AddForm.update(self)36 37 37 38 @grok.action('Add item') 38 39 def add(self, **data): 39 40 obj = self.context.childClass(**data) 40 try: 41 id = data['id'].lower() 42 self.context[id] = obj 43 except Exception, ex: 44 print ex 45 print data 46 raise ex 47 self.redirect(self.url('.')) 41 id = data['id'].lower() 42 self.context[id] = obj # schlägt fehlt bei nicht-Container-Objekten (not iterable) 43 self.redirect(self.url('@@index')) 48 44 49 45 class EditForm(grok.EditForm): 50 46 template = grok.PageTemplate(filename=os.path.join('basecontainer_templates', 'edit_form.pt')) 51 52 def update(self): 53 self.form_fields = grok.AutoFields(self.context) 54 grok.EditForm.update(self) 47 #form_fields = grok.AutoFields(BaseContainer) 48 49 def __init__(self, context, request): 50 super(EditForm, self).__init__(context, request) 51 self.form_fields = grok.AutoFields(self.context.__class__) 55 52 56 53 def handle_edit_action(self, **data): … … 74 71 class EditViewlet(grok.Viewlet): 75 72 grok.viewletmanager(vw.MainArea) 76 grok.context(IBaseContainer)73 #grok.context(IBaseContainer) 77 74 grok.view(vw.Edit) 78 75 #grok.name('edit') -
waeup/branches/hraban/src/waeup/basecontainer_templates/edit_form.pt
r3566 r3571 17 17 </div> 18 18 --> 19 <div tal:content="context"></div>20 19 <div class="form-fields"> 21 20 <tal:block repeat="widget view/widgets"> -
waeup/branches/hraban/src/waeup/baseitem.py
r3566 r3571 10 10 Base item 11 11 """ 12 grok.implements(IBaseItem)12 #grok.implements(IBaseItem) 13 13 14 14 def __init__(self, **kwargs): … … 26 26 template = grok.PageTemplate(filename=os.path.join('basecontainer_templates', 'edit_form.pt')) 27 27 28 def update(self):29 s elf.form_fields = grok.AutoFields(self.context.childClass)30 grok.AddForm.update(self)28 def __init__(self, context, request): 29 super(AddForm, self).__init__(context, request) 30 self.form_fields = grok.AutoFields(self.context-__class__) #.childClass) 31 31 32 32 @grok.action('Add item') 33 33 def add(self, **data): 34 obj = self.context. childClass(**data)34 obj = self.context.__class__(**data) #.childClass(**data) 35 35 id = data['id'].lower() 36 36 self.context[id] = obj … … 40 40 template = grok.PageTemplate(filename=os.path.join('basecontainer_templates', 'edit_form.pt')) 41 41 42 def update(self):43 s elf.form_fields = grok.AutoFields(self.context)44 grok.EditForm.update(self)45 42 def __init__(self, context, request): 43 super(EditForm, self).__init__(context, request) 44 self.form_fields = grok.AutoFields(self.context.__class__) 45 46 46 def handle_edit_action(self, **data): 47 47 grok.EditForm.handle_edit_action(self, **data) 48 self.redirect(self.url(' ..'))48 self.redirect(self.url('@@index')) 49 49 50 50 class AddViewlet(grok.Viewlet): -
waeup/branches/hraban/src/waeup/catalog.py
r3557 r3571 1 import sys2 import csv3 import random4 from datetime import datetime5 import os6 1 import grok, grok.index 7 2 from hurry.query.query import Query, Text 8 3 from hurry.query import Eq 9 4 from waeup.app import University 10 from waeup.students.interfaces import IStudent 5 from waeup.students.interfaces import IStudent, IStudentContainer 11 6 from waeup.students.student import Student 12 7 from waeup.viewlets import MainArea, LeftSidebar … … 15 10 grok.site(University) 16 11 grok.name('students_catalog') 17 grok.context(IStudent )12 grok.context(IStudentContainer) 18 13 19 14 name = grok.index.Field(attribute='name') … … 21 16 22 17 class StudentSearch(grok.Viewlet): 23 grok.context(IStudent )18 grok.context(IStudentContainer) 24 19 grok.viewletmanager(LeftSidebar) 25 20 #grok.view(Student) 21 grok.order(3) 26 22 27 23 def update(self, query=None): -
waeup/branches/hraban/src/waeup/catalog_templates/studentsearch.pt
r3562 r3571 7 7 <input type="submit" value="Search" /> 8 8 </form> 9 <!-- 9 10 <ul> 10 11 <li tal:repeat="item view/search_result" … … 12 13 </li> 13 14 </ul> 15 --> 14 16 </div> -
waeup/branches/hraban/src/waeup/hostel/hostel.py
r3566 r3571 9 9 grok.implements(IHostel) 10 10 name = u'Hostel' 11 #childClass = ?12 13 14 #class Add(base.AddViewlet):15 # grok.context(IHostel)16 #17 #class Edit(base.EditViewlet):18 # grok.context(IHostel)19 #20 #class EditForm(base.EditForm):21 # pass22 #23 #class AddForm(base.AddForm):24 # pass -
waeup/branches/hraban/src/waeup/hostel/hostelcontainer.py
r3566 r3571 1 1 import grok 2 from waeup. interfaces import IBaseContainer2 from waeup.hostel.interfaces import IHostelContainer 3 3 from waeup.basecontainer import BaseContainer 4 4 from hostel import Hostel 5 5 6 6 class HostelContainer(BaseContainer): 7 grok.implements(IBaseContainer) 7 grok.implements(IHostelContainer) 8 id = 'hostels' 8 9 name = u"Hostels" 9 10 childClass = Hostel -
waeup/branches/hraban/src/waeup/hostel/interfaces.py
r3566 r3571 4 4 import re 5 5 from zope import schema 6 from waeup.interfaces import IBase Container6 from waeup.interfaces import IBaseItem, IBaseContainer 7 7 8 class IHostel(IBase Container):8 class IHostel(IBaseItem): 9 9 """Representation of a hostel (AKA hall). 10 10 """ … … 21 21 ) 22 22 23 class IHostelContainer(IBaseContainer): 24 pass -
waeup/branches/hraban/src/waeup/students/interfaces.py
r3566 r3571 4 4 import re 5 5 from zope import schema 6 from waeup.interfaces import IBaseItem 6 from zope.interface import Interface 7 from waeup.interfaces import IBaseItem, IBaseContainer 7 8 8 class IStudent(IBaseItem): 9 class IStudentContainer(IBaseContainer): 10 pass 11 12 class IStudent(Interface): 9 13 """Representation of a student. 10 14 """ 15 id = schema.ASCIILine( 16 title = u'Student ID', 17 default = '', 18 required = True, 19 constraint=(re.compile("^([A-Z]\d{6})?$").match) 20 ) 11 21 entry_mode = schema.ASCIILine( # Choice? 12 22 title = u'Entry Mode', … … 39 49 min = 0, 40 50 max = 600 41 )42 id = schema.ASCIILine(43 title = u'Student ID',44 default = '',45 required = False,46 constraint=(re.compile("^([A-Z]\d{6})?$").match)47 51 ) 48 52 lga = schema.TextLine( -
waeup/branches/hraban/src/waeup/students/student.py
r3566 r3571 21 21 name = u'Student' 22 22 23 #TODO: REFACTOR TO SCHEMA24 23 fields = [ "entry_mode", 25 24 "end_level", … … 50 49 51 50 52 class Add(base.AddViewlet):53 grok.context(IStudent)54 55 class Edit(base.EditViewlet):56 grok.context(IStudent)51 #class AddViewlet(base.AddViewlet): 52 # grok.context(IStudent) 53 # 54 #class EditEditViewlet(base.EditViewlet): 55 # grok.context(IStudent) -
waeup/branches/hraban/src/waeup/students/studentcontainer.py
r3566 r3571 1 1 import grok 2 2 import os 3 from waeup.interfaces import IBaseContainer3 #from waeup.interfaces import IBaseContainer 4 4 import waeup.basecontainer as base 5 from student import Student, fromCsv 5 from waeup.students.student import Student, fromCsv 6 from waeup.students.interfaces import IStudentContainer 6 7 from waeup.utils import importexport as csv 7 8 … … 11 12 The node containing the student models 12 13 """ 14 grok.implements(IStudentContainer) 15 id = 'students' 13 16 name = u"Students" 14 17 childClass = Student … … 42 45 return "yeah %s" % t[0] 43 46 47 #class AddForm(base.AddForm): 48 # form_fields = grok.AutoFields(Student) 49 # 50 #class EditForm(base.EditForm): 51 # form_fields = grok.AutoFields(Student) 44 52 45 class Edit(base.EditViewlet): 46 grok.context(IBaseContainer) 53 54 #class Edit(base.EditViewlet): 55 # grok.context(IStudentContainer) 56 # 57 # 58 #class Add(base.AddViewlet): 59 # grok.context(IStudentContainer) -
waeup/branches/hraban/src/waeup/university/course.py
r3566 r3571 3 3 from waeup.university.interfaces import ICourse 4 4 5 class Department(base.BaseItem):5 class Course(grok.Model): 6 6 grok.implements(ICourse) 7 7 name = u'Course' -
waeup/branches/hraban/src/waeup/university/department.py
r3566 r3571 9 9 name = u'Department' 10 10 11 class Add(base.AddViewlet):12 grok.context(IDepartment)11 #class Add(base.AddViewlet): 12 # grok.context(IDepartment) 13 13 14 14 -
waeup/branches/hraban/src/waeup/university/facultycontainer.py
r3566 r3571 1 1 import grok 2 2 from waeup.basecontainer import BaseContainer 3 from waeup.interfaces import IBaseContainer 3 4 from waeup.university.interfaces import IFaculty 4 5 from waeup.university.faculty import Faculty 5 6 6 7 class FacultyContainer(BaseContainer): 7 #grok.implements(IBaseContainer) 8 grok.implements(IBaseContainer) 9 id = 'faculties' 8 10 name = u'Faculties' 9 11 childClass = Faculty -
waeup/branches/hraban/src/waeup/university/interfaces.py
r3566 r3571 4 4 from waeup.interfaces import IBaseContainer 5 5 6 class IFaculty( IBaseContainer):6 class IFaculty(grok.interfaces.IContainer): 7 7 """Representation of a university faculty. 8 8 """
Note: See TracChangeset for help on using the changeset viewer.