rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
rollcall = dlg.getRollCall() try: self.client.submitRollCall(group_href, rollcall) except SchoolToolError, e: self.SetStatusText(str(e)) else: self.SetStatusText(self.client.status)
self.SetStatusText(self.client.status)
def DoRollCall(self, event=None): """Open the roll call dialog.
adapts(IPerson)
def contains(self, principal): return IPerson(principal, None) in self.context.instructors
for section in self._getSections(self.context):
for section in self._getSections(person):
def contains(self, principal): user = IPerson(principal, None) # First check the the sections a pupil is in directly for section in self._getSections(self.context): if user in section.instructors: return True # Now check the section membership via groups for group in self.context.groups: for section in self._getSection...
for group in self.context.groups:
for group in person.groups:
def contains(self, principal): user = IPerson(principal, None) # First check the the sections a pupil is in directly for section in self._getSections(self.context): if user in section.instructors: return True # Now check the section membership via groups for group in self.context.groups: for section in self._getSection...
<include package="zope.app.securitypolicy" file="securitypolicy.zcml" />
<include package="zope.app.securitypolicy"/> <!-- Basically a copy of zope.app.securitypolicy/securitypolicy.zcml --> <securityPolicy component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" /> <role id="zope.Anonymous" title="Everybody" description="All users have this role implicitly" /> <role id="zope.Ma...
def daemonize(): """Daemonize with a double fork and close the standard IO.""" pid = os.fork() if pid: sys.exit(0) os.setsid() os.umask(077) pid = os.fork() if pid: print _("Going to background, daemon pid %d" % pid) sys.exit(0) os.close(0) os.close(1) os.close(2) os.open('/dev/null', os.O_RDWR) os.dup(0) os.dup(0)
if datetime not in self._records: self._records[datetime] = ()
self._records.setdefault(datetime, ())
def record(self, section, datetime, duration, period_id, present): if self.get(section, datetime).status != UNKNOWN: raise AttendanceError('record for %s at %s already exists' % (section, datetime)) if present: status = PRESENT else: status = ABSENT
required=False,
required=True,
def setPassword(password): """Set the password in a hashed form, so it can be verified later.
do('python setup.py install --prefix here')
do('python setup.py install --home `pwd`/here') zope3_path = os.path.abspath(os.curdir + '/../../Zope3/src') do('export PYTHONPATH=%s' %zope3_path) os.chdir('here/lib/python') tests_path = os.path.abspath(os.curdir + '/schooltool/relationship/tests') for fn in os.listdir(tests_path): if fn.startswith('test') and fn.e...
def do(command): print command if os.system(command): sys.exit(1)
self.chooser = SimpleNameChooser(self.groups)
self.chooser = SimpleNameChooser(container)
def __init__(self, container, charset=None): BaseCSVImporter.__init__(self, container, charset) self.groups = container self.chooser = SimpleNameChooser(self.groups)
name = self.chooser.chooseName(group.title, group)
name = self.chooser.chooseName('', group)
def createAndAdd(self, data, dry_run=True): """Create Group objects and add them to the group container. """ if len(data) < 1: self.errors.fields.append(_('Insufficient data provided.')) return
"""Return a list of tuples with group information
"""Return a list of tuples with group information.
def getGroups(): """Return a list of tuples with group information
"""Extracts the data and validates it.
"""Extract the data and validates it.
def parseData(self, body): """Extracts the data and validates it.
... ['localhost', 48080])
... [('localhost', 48080)])
def doctest_load_options(): """Tests for load_options(). We will use a sample configuration file that comes with these tests. >>> import os >>> from schoolbell.app import tests >>> test_dir = os.path.dirname(tests.__file__) >>> sample_config_file = os.path.join(test_dir, 'sample.conf') >>> empty_config_file = os.path...
r"""Remove leading indentation from tripple quoted strings.
r"""Remove leading indentation from triple-quoted strings.
def dedent(text): r"""Remove leading indentation from tripple quoted strings. Example: >>> dedent(''' ... some text ... is here ... with maybe some indents ... ''') ... 'some text\nis here\n with maybe some indents\n' Corner cases (mixing tabs and spaces, lines that are indented less than the fi...
class ResourceCalendarCrowd(ConfigurableCrowd, LeaderCrowd):
class ResourceViewersCrowd(ConfigurableCrowd): setting_key = 'everyone_can_view_resource_info' class ResourceContainerViewersCrowd(ConfigurableCrowd): setting_key = 'everyone_can_view_resource_list' class ResourceCalendarViewersCrowd(ConfigurableCrowd):
def addResourceContainerToApplication(event): event.object['resources'] = ResourceContainer()
if self.paths: paths_str = '\n'.join([' + ['sys.path.insert(0, %s)' % repr(path)\ for path in self.paths.split(';')] + [' else: paths_str = '\n'.join(['
def update_scripts(self): for script in self.get_outputs(): # Read the installed script try: script_file = open(script, 'r') script_str = script_file.read() finally: script_file.close() # Update the paths in the script if self.paths: paths_str = '\n'.join(['# paths begin'] + ['sys.path.insert(0, %s)' % repr(path)\ for ...
script_str = re.sub(paths_regex, paths_str, script_str)
paths = [' for path in self.paths.split(';'): paths.insert(-1, 'sys.path.insert(0, %s)' \ % repr(os.path.abspath(path))) script_str = re.sub(paths_regex, '\n'.join(paths), script_str)
def update_scripts(self): for script in self.get_outputs(): # Read the installed script try: script_file = open(script, 'r') script_str = script_file.read() finally: script_file.close() # Update the paths in the script if self.paths: paths_str = '\n'.join(['# paths begin'] + ['sys.path.insert(0, %s)' % repr(path)\ for ...
config_str = '\n'.join([' 'sys.argv.insert(1, \'--config=%s\')' % self.default_config, ' else: config_str = '\n'.join([' "sys.argv.insert(1, \'--config=%s\' % " "__file__ + \'.conf\')", ' config_regex = re.compile(r' script_str = re.sub(config_regex, config_str, script_str)
config[1] = 'sys.argv.insert(1, \'--config=%s\')'\ % os.path.abspath(self.default_config) script_str = re.sub(config_regex, '\n'.join(config), script_str)
def update_scripts(self): for script in self.get_outputs(): # Read the installed script try: script_file = open(script, 'r') script_str = script_file.read() finally: script_file.close() # Update the paths in the script if self.paths: paths_str = '\n'.join(['# paths begin'] + ['sys.path.insert(0, %s)' % repr(path)\ for ...
return _('%(month)s, %(year)s') % { 'month': month_name, 'year': self.cursor.year, }
args = {'month': month_name, 'year': self.cursor.year} return _('%(month)s, %(year)s') % args
def title(self): month_name = unicode(self.month_names[self.cursor.month]) return _('%(month)s, %(year)s') % { 'month': month_name, 'year': self.cursor.year, }
def initialize_options(self): self.build_base = None return _install_data.initialize_options(self) def finalize_options(self): self.set_undefined_options('install', ('build_base', 'build_base')) return _install_data.finalize_options(self) def run(self): """Record where we have installed the data files""" self.run_co...
def initialize_options(self): self.build_base = None return _install_data.initialize_options(self)
self.build_base = None
def initialize_options(self): self.datafile_dir = None self.build_base = None self.build_lib = None return _install_lib.initialize_options(self)
('build_base', 'build_base'), ('build_lib', 'build_lib'))
('build_lib', 'build_lib'), ('install_data', 'datafile_dir'))
def finalize_options(self): self.set_undefined_options('install', ('build_base', 'build_base'), ('build_lib', 'build_lib')) return _install_lib.finalize_options(self)
if self.datafile_dir is None: self.run_command('install_data') try: data_file = open(os.path.join(self.build_base, self.package + '_data_base'), 'r') self.datafile_dir = data_file.read() finally: data_file.close()
if self.package == 'schoolbell': if os.path.abspath(self.datafile_dir) \ != os.path.abspath(self.install_dir): raise NotImplementedError("You are probably trying to install " "schoolbell data files and modules in different " "locations, this is not implemented.")
def update_pathconfig(self): # Write the new location to the pathconfig.py file. pathconfig = os.path.join(self.build_lib, self.package, 'pathconfig.py') if self.datafile_dir is None: # Make sure that we have installed the data files self.run_command('install_data') # Get the location of the installed data try: data_fi...
datafile_re = re.compile('.*\.(pt|js|png|css|mo|rng|xml|pot)\Z')
datafile_re = re.compile('.*\.(pt|js|png|css|mo|rng|xml|pot|zcml)\Z')
def run(self): ans = _install_scripts.run(self) self.update_scripts() return ans
cmdclass={'install_data': install_data,
cmdclass={'install': install,
def run(self): ans = _install_scripts.run(self) self.update_scripts() return ans
def getCourseFromId(self, id):
def getCourseFromId(self, cid):
def getCourseFromId(self, id): app = getSite() try: return app['courses'][id] except KeyError: self.error = _("No such course.")
return app['courses'][id]
return app['courses'][cid]
def getCourseFromId(self, id): app = getSite() try: return app['courses'][id] except KeyError: self.error = _("No such course.")
title = Attribute("""Person's name""")
title = Attribute("""Person's full name""")
def getFreeIntervals(first, last, time_periods, duration): """Returns all intervals of time not shorter than duration when the object is free within a range of dates [first, last] during the times of day specified by time_periods.
"""Retuns True if the password is the same as the one set
"""Check if the provided password is the same as the one set
def checkPassword(password): """Retuns True if the password is the same as the one set earlier using setPassword. """
row_ends = [today + timedelta(hours=hour + 1) for hour in range(self.starthour, self.endhour)]
row_ends = [today + timedelta(hours=hour) for hour in range(self.starthour, self.endhour+1)]
def calendarRows(self): """Iterate over (title, start, duration) of time slots that make up the daily calendar. """ # TODO: Refactor this into a view or adapter so that we don't have # to keep a copy of cal_daily.pt around. person = IPerson(self.request.principal, None) if person is not None: prefs = IPersonPrefe...
if pstart == dt: return True
return pstart == dt
def periodIsStarting(dt): if not periods: return False pstart = datetime.combine(self.cursor, periods[0].tstart) pstart = pstart.replace(tzinfo=self.timezone) if pstart == dt: return True
... site_definition = 'schooltool-site.zcml'
... site_definition = 'schooltool-skel/etc/site.zcml'
... def open(self):
>>> server.siteConfigFile = os.path.join(dir, 'schooltool-site.zcml')
>>> server.siteConfigFile = os.path.join( ... dir, 'schooltool-skel', 'etc', 'site.zcml')
def doctest_bootstrapSchoolTool(): r"""Tests for bootstrapSchoolTool() >>> from zope.app.testing import setup >>> setup.placelessSetUp() Normally, bootstrapSchoolTool is called when Zope 3 is fully configured >>> from schooltool.app.main import StandaloneServer >>> server = StandaloneServer() >>> import schooltool ...
>>> server.siteConfigFile = os.path.join(dir, 'schooltool-site.zcml')
>>> server.siteConfigFile = os.path.join( ... dir, 'schooltool-skel', 'etc', 'site.zcml')
def doctest_restoreManagerUser(): """Unittest for StandaloneServer.restoreManagerUser >>> from zope.app.testing import setup >>> setup.placelessSetUp() We need a configured server: >>> from schooltool.app.main import StandaloneServer >>> server = StandaloneServer() >>> import schooltool >>> dir = os.path.join(os.pa...
print >> f, _('"Hall"')
print >> f, '"%s"' % (_('Hall'), )
def createResources(): """Create a generated resources.csv in the current directory. Format of the file: title """ f = open("resources.csv", "w") print >> f, _('"Hall"') for i in range(1,10): print >> f, _('"Room %d"') % i for i in range(1,4): print >> f, _('"Projector %d"') % i f.close()
print >> f, _('"Room %d"') % i
print >> f, '"%s"' % (_('Room %d') % i, )
def createResources(): """Create a generated resources.csv in the current directory. Format of the file: title """ f = open("resources.csv", "w") print >> f, _('"Hall"') for i in range(1,10): print >> f, _('"Room %d"') % i for i in range(1,4): print >> f, _('"Projector %d"') % i f.close()
print >> f, _('"Projector %d"') % i
print >> f, '"%s"' % (_('Projector %d') % i, )
def createResources(): """Create a generated resources.csv in the current directory. Format of the file: title """ f = open("resources.csv", "w") print >> f, _('"Hall"') for i in range(1,10): print >> f, _('"Room %d"') % i for i in range(1,4): print >> f, _('"Projector %d"') % i f.close()
for name in self._order:
for name in list(self._order):
def removeBase(self, base): """See interfaces.IRequirement""" self.bases.remove(base) base.subs.remove(self) for name, value in self._data.items(): if name in base: value.removeBase(base[name])
""" % {'unauth_user': _("Unauthenticated User"), 'unauth_users': _("Unauthenticated Users"), 'auth_users': _("Unauthenticated Users"), 'all_users': _("All Users")}
""" % {'unauth_user': catalog.ugettext("Unauthenticated User"), 'unauth_users': catalog.ugettext("Unauthenticated Users"), 'auth_users': catalog.ugettext("Authenticated Users"), 'all_users': catalog.ugettext("All Users")} _("Unauthenticated User"), _("Unauthenticated Users") _("Authenticated Users"), _("All Users") ...
def daemonize(): """Daemonize with a double fork and close the standard IO.""" pid = os.fork() if pid: sys.exit(0) os.setsid() os.umask(077) pid = os.fork() if pid: print _("Going to background, daemon pid %d" % pid) sys.exit(0) os.close(0) os.close(1) os.close(2) os.open('/dev/null', os.O_RDWR) os.dup(0) os.dup(0)
>>> for period in exception:
>>> periods = list(exception) >>> periods.sort(lambda x, y: cmp(x.tstart, y.tstart)) >>> for period in periods:
def doctest_SpecialDayView(): """SpecialDayView tests. Special days are days for which some periods are shortened or cancelled altogether. Our view for that presents the administrator with a way to alter the schoolday template for this day. First of all, we need an app object: >>> from schooltool.tests import setUp...
Lets add him to the container
Let's add him to the container
def test_personContainerView(): r"""Test for PersonContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) ...
Lets add another person to the container
Let's add another person to the container
def test_personContainerView(): r"""Test for PersonContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) ...
Lets create a view
Let's create a view
def test_personContainerView(): r"""Test for PersonContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) ...
Lets get a sorted by title object list
Let's get a sorted by title object list
def test_personContainerView(): r"""Test for PersonContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) ...
Lets add it to the container
Let's add it to the container
def test_groupContainerView(): r"""Test for GroupContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) Le...
Lets add another group to the container
Let's add another group to the container
def test_groupContainerView(): r"""Test for GroupContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) Le...
Lets create a view
Let's create a view
def test_groupContainerView(): r"""Test for GroupContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) Le...
Lets get a sorted by title object list
Let's get a sorted by title object list
def test_groupContainerView(): r"""Test for GroupContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) Le...
Lets add it to the container
Let's add it to the container
def test_resourceContainerView(): r"""Test for ResourceContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoo...
Lets add another resource to the container
Let's add another resource to the container
def test_resourceContainerView(): r"""Test for ResourceContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoo...
Lets create a view
Let's create a view
def test_resourceContainerView(): r"""Test for ResourceContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoo...
Lets get a sorted by title object list
Let's get a sorted by title object list
def test_resourceContainerView(): r"""Test for ResourceContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoo...
Let's create a new person:
We will need a person that has a photo:
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
>>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis"
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
Let's create a person photo view
We can now create a view: >>> from schoolbell.app.browser.app import PersonPhotoView
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
>>> from schoolbell.app.browser.app import PersonPhotoView
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
We should see the photo >>> view.__call__()
The view returns the photo and sets the appropriate Content-Type header: >>> view()
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
The photo should be jpeg
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
But if a person has no photo
However, if a person has no photo, the view raises a NotFound error.
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
We should get an exception >>> view.__call__()
>>> view()
def test_personPhotoView(): r"""Test for PersonPhotoView Let's create a new person: >>> from schoolbell.app.app import Person >>> person = Person() >>> person.__name__ = "Jonas" >>> person.title = "Jonas Petraitis" >>> person.photo = "I am a photo!" Let's create a person photo view >>> request = TestRequest() >>> fr...
else: raise KeyError(key)
raise KeyError(key)
def __getitem__(self, key): """See interface `IReadContainer`""" try: return self._data[key] except KeyError: for base in self.bases: if key in base: return InheritedRequirement(base[key], self, key) else: raise KeyError(key)
return key in self._data
return key in self.keys()
def __contains__(self, key): """See interface `IReadContainer`""" return key in self._data
print >> sys.stderr, 'run %s -h for help'
print >> sys.stderr, 'run %s -h for help' % argv[0]
def main(argv): """Main program.""" # Environment if sys.version_info < (2, 3): print >> sys.stderr, '%s: need Python 2.3 or later' % argv[0] print >> sys.stderr, 'your python is %s' % sys.version return 1 # Defaults cfg = Options() cfg.basedir = os.path.join(os.path.dirname(argv[0]), 'src') cfg.basedir = os.path.abs...
searchstr = to_unicode(self.request.args['SEARCH'][0]).lower()
try: searchstr = to_unicode(self.request.args['SEARCH'][0]).lower() except UnicodeError: return []
def addList(self): """Return a list of objects available for addition""" searchstr = to_unicode(self.request.args['SEARCH'][0]).lower() members = sets.Set(getRelatedObjects(self.context, URIMember)) addable = [] for path in ('/groups', '/persons', '/resources'): for obj in traverse(self.context, path).itervalues(): if ...
title = to_unicode(request.args['title'][0]) self.context.title = title
self.title_widget.update(request) if self.title_widget.raw_value == '': self.title_widget.setRawValue(None) self.title_widget.require() if self.title_widget.error: return self.do_GET(request) self.context.title = self.title_widget.value
def do_POST(self, request): title = to_unicode(request.args['title'][0]) self.context.title = title
print event
def _addTimetableException(self, event, replacement): """Add or change a timetable exception for a timetable event.
self.peopleListBox.SetStringSelection(old_selection)
idx = self.peopleListBox.FindString(old_selection) if idx != -1: self.peopleListBox.SetSelection(idx)
def refresh(self): people = self.client.getListOfPersons() self.SetStatusText(self.client.status) old_selection = self.peopleListBox.GetStringSelection() self.peopleListBox.Set(people) self.peopleListBox.SetStringSelection(old_selection) self.personInfoText.SetPage('') self.DoSelectPerson(None)
self.owner_name = owner_name = to_unicode(request.args['owner'][0])
self.owner_name = to_unicode(request.args['owner'][0])
def update(self): request = self.request if 'CONFIRM_BOOK' not in request.args: if 'start' in request.args: start = to_unicode(request.args['start'][0]) parts = start.split(' ') self.start_date = parts[0] self.start_time = ":".join(parts[1].split(':')[:2]) if 'mins' in request.args: self.duration = to_unicode(request.a...
owner = persons[owner_name]
owner = persons[self.owner_name]
def update(self): request = self.request if 'CONFIRM_BOOK' not in request.args: if 'start' in request.args: start = to_unicode(request.args['start'][0]) parts = start.split(' ') self.start_date = parts[0] self.start_time = ":".join(parts[1].split(':')[:2]) if 'mins' in request.args: self.duration = to_unicode(request.a...
self.error = _("Invalid owner: %s") % owner_name
self.error = _("Invalid owner: %s") % self.owner_name
def update(self): request = self.request if 'CONFIRM_BOOK' not in request.args: if 'start' in request.args: start = to_unicode(request.args['start'][0]) parts = start.split(' ') self.start_date = parts[0] self.start_time = ":".join(parts[1].split(':')[:2]) if 'mins' in request.args: self.duration = to_unicode(request.a...
if event.__parent__ is self.context and calendar is not self.context:
if (removeSecurityProxy(event.__parent__) is removeSecurityProxy(self.context) and calendar is not self.context):
def getEvents(self, start_dt, end_dt): """Get a list of EventForDisplay objects for a selected time interval.
class ScriptTestCase(unittest.TestCase):
class ScriptTestCase(setup.TestCase):
def run(self): self.result = self.pipe.read() self.pipe.close()
client_args = '-p 8813'
def run(self): self.result = self.pipe.read() self.pipe.close()
return self.id()
return self.test_id
def __str__(self): return self.id()
return self.redirect_template(request, destination=url, view=self)
return self.redirect_template(request, destination=url, view=self, context=self.context)
def redirect(self, url, request): """Redirect to a URL and return a html page explaining the redirect.""" if '://' not in url: if not url.startswith('/'): url = '/' + url scheme = request.isSecure() and 'https' or 'http' hostname = request.getRequestHostname() port = request.getHost().port url = '%s://%s:%s%s' % (schem...
def getPersonInfo(self):
def test_getPersonInfo(self):
def getPersonInfo(self): from schooltool.wxclient import SchoolToolClient body = ( '<html>\n' ' <h1>Foo!</h1>\n' '</html>\n' ) version = 'UnitTest/0.0' person_id = 'foo' response = ResponseStub(200, 'OK', body, server=version) factory = ConnectionFactory(response) client = SchoolToolClient() client.connectionFactory =...
install_requires=['zc.table >= 0.5', 'zc.catalog >= 0.1',
install_requires=['zc.resourcelibrary >= 0.5.1', 'zc.table >= 0.5', 'zc.catalog >= 0.1',
def get_version(): version_file = os.path.join('src', 'schooltool', 'version.txt') f = open(version_file, 'r') result = f.read() f.close() return result
'next.png', 'prev.png', 'favicon.ico']:
'next.png', 'prev.png', 'favicon.ico', 'calwidget-calendar.js', 'calwidget-calendar.css', 'calwidget-icon.gif']:
def __call__(self): return "a dummy resource"
today = datetime.combine(self.cursor, time())
today = datetime.combine(self.cursor, time(tzinfo=utc))
def calendarRows(self): """Iterate over (title, start, duration) of time slots that make up the daily calendar. """ person = IPerson(self.request.principal, None) if person is not None: prefs = IPersonPreferences(person) show_periods = prefs.cal_periods else: show_periods = False
tal:condition="not:user/schoolbell:authenticated"
tal:condition="not:user/schoolbell:authenticated">
def authenticated(self): """Check whether context is an authenticated principal.
install_db_bootstrap_hook()
def load_ftesting_zcml(): """Find SchoolTool's ftesting.zcml and load it. Can be safely called more than once. """ # Find SchoolTool's ftesting.zcml and load it. try: FunctionalTestSetup(find_ftesting_zcml()) except NotImplementedError, e: # It appears that some other ftesting.zcml was already loaded, which # is perfe...
except NotImplementedError, e: if str(e) != 'Already configured with a different config file': raise
finally: uninstall_db_bootstrap_hook()
def load_ftesting_zcml(): """Find SchoolTool's ftesting.zcml and load it. Can be safely called more than once. """ # Find SchoolTool's ftesting.zcml and load it. try: FunctionalTestSetup(find_ftesting_zcml()) except NotImplementedError, e: # It appears that some other ftesting.zcml was already loaded, which # is perfe...
raise KeyError(unique_id)
else: raise KeyError(unique_id)
def find(self, unique_id): # We could speed this method up by building and maintaining an index. for event in self: if event.unique_id == unique_id: return event raise KeyError(unique_id)
v = 'Basic ' + v[len('Basic '):].encode('base64')
v = 'Basic ' + v[len('Basic '):].encode('base64').strip()
def make_http_request(host, port, request_string): """Make a HTTP request and return the response as a string.""" # Discard leading white space to make call layout simpler request_string = request_string.lstrip() # split off and parse the command line l = request_string.find('\n') command_line = request_string[:l].rst...
body = instream.read()
body = instream.read().rstrip()
def make_http_request(host, port, request_string): """Make a HTTP request and return the response as a string.""" # Discard leading white space to make call layout simpler request_string = request_string.lstrip() # split off and parse the command line l = request_string.find('\n') command_line = request_string[:l].rst...
self.title, id(self))
self.title, nonneg_id)
def __repr__(self): return "<%s object %s at 0x%x>" % (self.__class__.__name__, self.title, id(self))
key = PythonIdentifier("""A key that identified the setting.
key = PythonIdentifier(description=u"""A key that identified the setting.
def __iter__(): """Iterate through all customisation settings."""
'teachers_edit_person_info''
'teachers_edit_person_info'
def __iter__(): """Iterate through all customisation settings."""
default = Bool("The default value for the setting.") text = TextLine("Description of the setting for the user interface.")
default = Bool(title=u"The default value for the setting.") text = TextLine(title=u"Description of the setting for the user interface.")
def __iter__(): """Iterate through all customisation settings."""
'Person index'
u'Person index'
def test_personContainerView(): r"""Test for PersonContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) ...
'Add a new person'
u'Add a new person'
def test_personContainerView(): r"""Test for PersonContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) ...
'Group index'
u'Group index'
def test_groupContainerView(): r"""Test for GroupContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) Le...
'Add a new group'
u'Add a new group'
def test_groupContainerView(): r"""Test for GroupContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoot) Le...
'Resource index'
u'Resource index'
def test_resourceContainerView(): r"""Test for ResourceContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoo...
'Add a new resource'
u'Add a new resource'
def test_resourceContainerView(): r"""Test for ResourceContainerView We will need to set up the environment for the test: >>> setup.placelessSetUp() >>> from schoolbell.app.app import SchoolBellApplication >>> schoolBellApplication = SchoolBellApplication() >>> directlyProvides(schoolBellApplication, IContainmentRoo...
Klara Phillips Cath Rodriguez
def doctest_SampleStudents(): """A sample data plugin that generates students >>> from schooltool.demographics.sampledata import SampleStudents >>> from schooltool.sampledata.interfaces import ISampleDataPlugin >>> plugin = SampleStudents() >>> verifyObject(ISampleDataPlugin, plugin) True This plugin simply creates a...
Gabbie Cunningham
Jeffery Hardy Thelma Vaughn Pip Stewart
def doctest_SampleStudents(): """A sample data plugin that generates students >>> from schooltool.demographics.sampledata import SampleStudents >>> from schooltool.sampledata.interfaces import ISampleDataPlugin >>> plugin = SampleStudents() >>> verifyObject(ISampleDataPlugin, plugin) True This plugin simply creates a...
... print app['persons']['teacher%03d' % i].title Catherine Martin Kimmy Cooper Helen Patterson Iris Laurent Philippa Stewart
... teacher = app['persons']['teacher%03d' % i] ... print teacher.title, (teacher.nameinfo.first_name, ... teacher.nameinfo.last_name) Catherine Martin ('Catherine', 'Martin') Kimmy Cooper ('Kimmy', 'Cooper') Helen Patterson ('Helen', 'Patterson') Iris Laurent ('Iris', 'Laurent') Phili...
def doctest_SampleTeachers(): """A sample data plugin that generates students >>> setUpRelationships() >>> from schooltool.demographics.sampledata import SampleTeachers >>> from schooltool.sampledata.interfaces import ISampleDataPlugin >>> plugin = SampleTeachers() >>> verifyObject(ISampleDataPlugin, plugin) True Th...
142 124 149 140 131
233 250 227 252 248
def doctest_SamplePersonalEvents(): """A sample data plugin that generates random personal events. >>> setUpRelationships() >>> from schooltool.demographics.sampledata import SamplePersonalEvents >>> from schooltool.sampledata.interfaces import ISampleDataPlugin >>> plugin = SamplePersonalEvents() >>> verifyObject(IS...
154
240
def doctest_SamplePersonalEvents(): """A sample data plugin that generates random personal events. >>> setUpRelationships() >>> from schooltool.demographics.sampledata import SamplePersonalEvents >>> from schooltool.sampledata.interfaces import ISampleDataPlugin >>> plugin = SamplePersonalEvents() >>> verifyObject(IS...