Changeset 3571 for waeup/branches


Ignore:
Timestamp:
14 Jul 2008, 21:36:49 (16 years ago)
Author:
hraban
Message:

getting close to a working stub :-)

Location:
waeup/branches/hraban/src/waeup
Files:
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/hraban/src/waeup/app.py

    r3566 r3571  
    22#from zope.interface import Interface
    33from waeup.interfaces import IUniversity
    4 from setup import app_setup
    54from waeup.viewlets import MainArea
    65from basecontainer import BaseContainer
     6from waeup.hostel import hostelcontainer
     7from waeup.university import facultycontainer
     8from waeup.students import studentcontainer
    79
    810class University(grok.Application, BaseContainer):
    911    grok.implements(IUniversity)
     12    id = 'base'
     13    name = u'University'
    1014
    1115    def __init__(self, **kw):
    1216        super(University, self).__init__(**kw)
    1317        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
    1527
    1628#class Content(grok.Viewlet):
  • waeup/branches/hraban/src/waeup/basecontainer.py

    r3566 r3571  
     1# -*- coding: utf-8 -*-
    12import grok
    23import os
     
    1011    base methods attached to it
    1112    """
    12     grok.implements(IBaseContainer)
    13     id = 'base'
    14     name = u"BaseContainer"
     13    #grok.implements(IBaseContainer)
     14    #id = 'base'
     15    #name = u"BaseContainer"
    1516    childClass = None
    1617    specialActions = []
     
    3132    template = grok.PageTemplate(filename=os.path.join('basecontainer_templates', 'edit_form.pt'))
    3233
    33     def update(self):
     34    def __init__(self, context, request):
     35        super(AddForm, self).__init__(context, request)
    3436        self.form_fields = grok.AutoFields(self.context.childClass)
    35         grok.AddForm.update(self)
    3637
    3738    @grok.action('Add item')
    3839    def add(self, **data):
    3940        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'))
    4844
    4945class EditForm(grok.EditForm):
    5046    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__)
    5552       
    5653    def handle_edit_action(self, **data):
     
    7471class EditViewlet(grok.Viewlet):
    7572    grok.viewletmanager(vw.MainArea)
    76     grok.context(IBaseContainer)
     73    #grok.context(IBaseContainer)
    7774    grok.view(vw.Edit)
    7875    #grok.name('edit')
  • waeup/branches/hraban/src/waeup/basecontainer_templates/edit_form.pt

    r3566 r3571  
    1717    </div>
    1818    -->
    19         <div tal:content="context"></div>
    2019    <div class="form-fields">
    2120        <tal:block repeat="widget view/widgets">
  • waeup/branches/hraban/src/waeup/baseitem.py

    r3566 r3571  
    1010    Base item
    1111    """
    12     grok.implements(IBaseItem)
     12    #grok.implements(IBaseItem)
    1313   
    1414    def __init__(self, **kwargs):
     
    2626    template = grok.PageTemplate(filename=os.path.join('basecontainer_templates', 'edit_form.pt'))
    2727
    28     def update(self):
    29         self.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)
    3131
    3232    @grok.action('Add item')
    3333    def add(self, **data):
    34         obj = self.context.childClass(**data)
     34        obj = self.context.__class__(**data) #.childClass(**data)
    3535        id = data['id'].lower()
    3636        self.context[id] = obj
     
    4040    template = grok.PageTemplate(filename=os.path.join('basecontainer_templates', 'edit_form.pt'))
    4141   
    42     def update(self):
    43         self.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       
    4646    def handle_edit_action(self, **data):
    4747        grok.EditForm.handle_edit_action(self, **data)
    48         self.redirect(self.url('..'))
     48        self.redirect(self.url('@@index'))
    4949
    5050class AddViewlet(grok.Viewlet):
  • waeup/branches/hraban/src/waeup/catalog.py

    r3557 r3571  
    1 import sys
    2 import csv
    3 import random
    4 from datetime import datetime
    5 import os
    61import grok, grok.index
    72from hurry.query.query import Query, Text
    83from hurry.query import Eq
    94from waeup.app import University
    10 from waeup.students.interfaces import IStudent
     5from waeup.students.interfaces import IStudent, IStudentContainer
    116from waeup.students.student import Student
    127from waeup.viewlets import MainArea, LeftSidebar
     
    1510     grok.site(University)
    1611     grok.name('students_catalog')
    17      grok.context(IStudent)
     12     grok.context(IStudentContainer)
    1813
    1914     name = grok.index.Field(attribute='name')
     
    2116
    2217class StudentSearch(grok.Viewlet):
    23     grok.context(IStudent)
     18    grok.context(IStudentContainer)
    2419    grok.viewletmanager(LeftSidebar)
    2520    #grok.view(Student)
     21    grok.order(3)
    2622
    2723    def update(self, query=None):
  • waeup/branches/hraban/src/waeup/catalog_templates/studentsearch.pt

    r3562 r3571  
    77    <input type="submit" value="Search" />
    88  </form>
     9  <!--
    910  <ul>
    1011  <li tal:repeat="item view/search_result"
     
    1213  </li>
    1314  </ul>
     15  -->
    1416</div>
  • waeup/branches/hraban/src/waeup/hostel/hostel.py

    r3566 r3571  
    99    grok.implements(IHostel)
    1010    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 #    pass
    22 #
    23 #class AddForm(base.AddForm):
    24 #    pass
  • waeup/branches/hraban/src/waeup/hostel/hostelcontainer.py

    r3566 r3571  
    11import grok
    2 from waeup.interfaces import IBaseContainer
     2from waeup.hostel.interfaces import IHostelContainer
    33from waeup.basecontainer import BaseContainer
    44from hostel import Hostel
    55
    66class HostelContainer(BaseContainer):
    7     grok.implements(IBaseContainer)
     7    grok.implements(IHostelContainer)
     8    id = 'hostels'
    89    name = u"Hostels"
    910    childClass = Hostel
  • waeup/branches/hraban/src/waeup/hostel/interfaces.py

    r3566 r3571  
    44import re
    55from zope import schema
    6 from waeup.interfaces import IBaseContainer
     6from waeup.interfaces import IBaseItem, IBaseContainer
    77
    8 class IHostel(IBaseContainer):
     8class IHostel(IBaseItem):
    99    """Representation of a hostel (AKA hall).
    1010    """
     
    2121        )
    2222
     23class IHostelContainer(IBaseContainer):
     24    pass
  • waeup/branches/hraban/src/waeup/students/interfaces.py

    r3566 r3571  
    44import re
    55from zope import schema
    6 from waeup.interfaces import IBaseItem
     6from zope.interface import Interface
     7from waeup.interfaces import IBaseItem, IBaseContainer
    78
    8 class IStudent(IBaseItem):
     9class IStudentContainer(IBaseContainer):
     10    pass
     11
     12class IStudent(Interface):
    913    """Representation of a student.
    1014    """
     15    id = schema.ASCIILine(
     16        title = u'Student ID',
     17        default = '',
     18        required = True,
     19        constraint=(re.compile("^([A-Z]\d{6})?$").match)
     20        )
    1121    entry_mode = schema.ASCIILine( # Choice?
    1222        title = u'Entry Mode',
     
    3949        min = 0,
    4050        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)
    4751        )
    4852    lga = schema.TextLine(
  • waeup/branches/hraban/src/waeup/students/student.py

    r3566 r3571  
    2121    name = u'Student'
    2222
    23     #TODO: REFACTOR TO SCHEMA
    2423    fields = [   "entry_mode",
    2524                 "end_level",
     
    5049
    5150
    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  
    11import grok
    22import os
    3 from waeup.interfaces import IBaseContainer
     3#from waeup.interfaces import IBaseContainer
    44import waeup.basecontainer as base
    5 from student import Student, fromCsv
     5from waeup.students.student import Student, fromCsv
     6from waeup.students.interfaces import IStudentContainer
    67from waeup.utils import importexport as csv
    78
     
    1112    The node containing the student models
    1213    """
     14    grok.implements(IStudentContainer)
     15    id = 'students'
    1316    name = u"Students"
    1417    childClass = Student
     
    4245        return "yeah %s" % t[0]
    4346
     47#class AddForm(base.AddForm):
     48#    form_fields = grok.AutoFields(Student)
     49#
     50#class EditForm(base.EditForm):
     51#    form_fields = grok.AutoFields(Student)
    4452
    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  
    33from waeup.university.interfaces import ICourse
    44
    5 class Department(base.BaseItem):
     5class Course(grok.Model):
    66    grok.implements(ICourse)
    77    name = u'Course'
  • waeup/branches/hraban/src/waeup/university/department.py

    r3566 r3571  
    99    name = u'Department'
    1010
    11 class Add(base.AddViewlet):
    12     grok.context(IDepartment)
     11#class Add(base.AddViewlet):
     12#    grok.context(IDepartment)
    1313
    1414
  • waeup/branches/hraban/src/waeup/university/facultycontainer.py

    r3566 r3571  
    11import grok
    22from waeup.basecontainer import BaseContainer
     3from waeup.interfaces import IBaseContainer
    34from waeup.university.interfaces import IFaculty
    45from waeup.university.faculty import Faculty
    56
    67class FacultyContainer(BaseContainer):
    7     #grok.implements(IBaseContainer)
     8    grok.implements(IBaseContainer)
     9    id = 'faculties'
    810    name = u'Faculties'
    911    childClass = Faculty
  • waeup/branches/hraban/src/waeup/university/interfaces.py

    r3566 r3571  
    44from waeup.interfaces import IBaseContainer
    55
    6 class IFaculty(IBaseContainer):
     6class IFaculty(grok.interfaces.IContainer):
    77    """Representation of a university faculty.
    88    """
Note: See TracChangeset for help on using the changeset viewer.