I have a product Course that defines a ZClass Course and several other Zclasses (Student, Submission, Section) etc... A course might be instantiated in a folder or at the root level, and can contain sections which can contain students, which can contain submissions and so on. I want to have a Course method called get_course which returns the Course instance, eg if I call http://server:8080/folder/BioSci101/Section12/BillStudent/TermPaper/some_met... ^ the Course ^ The Section ^ The Student In some_method_py, which is a python script, if the above URL is the context, I would like to be able to get the BioSci101 instance by calling get_course_py, eg folder = context.get_course_py() for section in folder.objectValues('Section'): for student in section.objectValues('Student') How can I get my hands on the Course instance? I might imagine traversing the parents, testing for isinstance of Course, or something to that effect, but I suspect there is a more direct way. And I do not know what the python equivalent of the PARENTS list is, or if I can use isinstance in python scripts. Thanks, John Hunter
John Hunter writes:
I have a product Course that defines a ZClass Course and several other Zclasses (Student, Submission, Section) etc... A course might be instantiated in a folder or at the root level, and can contain sections which can contain students, which can contain submissions and so on.
I want to have a Course method called get_course which returns the Course instance, eg if I call
http://server:8080/folder/BioSci101/Section12/BillStudent/TermPaper/some_met... ^ the Course ^ The Section ^ The Student
Try the following: Make a Python Script "get_course" with the body "return container". Apparently, the "container" of a Python Script ZClass method is the corresponding ZInstance. Dieter
participants (2)
-
Dieter Maurer -
John Hunter