Пример #1
0
 def zmi_page_request(self, *args, **kwargs):
     request = self.REQUEST
     RESPONSE = request.RESPONSE
     self._zmi_page_request()
     RESPONSE.setHeader(
         'Expires',
         DateTime(request['ZMI_TIME'] - 10000).toZone('GMT+1').rfc822())
     RESPONSE.setHeader('Cache-Control', 'no-cache')
     RESPONSE.setHeader('Pragma', 'no-cache')
     RESPONSE.setHeader('Content-Type',
                        'text/html;charset=%s' % request['ZMS_CHARSET'])
     if not request.get('preview'):
         request.set('preview', 'preview')
     langs = self.getLanguages(request)
     if request.get('lang') not in langs:
         request.set('lang', langs[0])
     if request.get(
             'manage_lang') not in self.getLocale().get_manage_langs():
         request.set('manage_lang', self.get_manage_lang())
     if not request.get('manage_tabs_message'):
         request.set('manage_tabs_message',
                     self.getConfProperty('ZMS.manage_tabs_message', ''))
     if 'zmi-manage-system' in request.form:
         standard.set_session_value(
             self, 'zmi-manage-system',
             int(request.get('zmi-manage-system', 0)))
     # manage must not be accessible for Anonymous
     if request['URL0'].find('/manage') >= 0:
         lower = self.getUserAttr(request['AUTHENTICATED_USER'],
                                  'attrActiveStart', '')
         upper = self.getUserAttr(request['AUTHENTICATED_USER'],
                                  'attrActiveEnd', '')
         if not standard.todayInRange(
                 lower, upper) or request['AUTHENTICATED_USER'].has_role(
                     'Anonymous'):
             import zExceptions
             raise zExceptions.Unauthorized
     # avoid declarative urls
     path_to_handle = request['URL0'][len(request['BASE0']):]
     path = path_to_handle.split('/')
     if not path[-2] in self.objectIds() \
         and len([x for x in path[:-1] if x.find('.')>0 or x.startswith('manage')])==0:
         new_path = self.absolute_url() + '/' + path[-1]
         if not new_path.endswith(path_to_handle):
             qs = request['QUERY_STRING']
             if qs:
                 new_path += '?' + qs
             request.RESPONSE.redirect(new_path)
Пример #2
0
 def zmi_page_request(self, *args, **kwargs):
     request = self.REQUEST
     RESPONSE = request.RESPONSE
     self._zmi_page_request()
     RESPONSE.setHeader(
         'Expires',
         DateTime(request['ZMI_TIME'] - 10000).toZone('GMT+1').rfc822())
     RESPONSE.setHeader('Cache-Control', 'no-cache')
     RESPONSE.setHeader('Pragma', 'no-cache')
     RESPONSE.setHeader('Content-Type',
                        'text/html;charset=%s' % request['ZMS_CHARSET'])
     if not request.get('preview'):
         request.set('preview', 'preview')
     langs = self.getLanguages(request)
     if request.get('lang') not in langs:
         request.set('lang', langs[0])
     if request.get(
             'manage_lang') not in self.getLocale().get_manage_langs():
         request.set('manage_lang', self.get_manage_lang())
     if not request.get('manage_tabs_message'):
         request.set('manage_tabs_message',
                     self.getConfProperty('ZMS.manage_tabs_message', ''))
     if 'zmi-manage-system' in request.form:
         standard.set_session_value(
             self, 'zmi-manage-system',
             int(request.get('zmi-manage-system', 0)))
     # AccessableObject
     _accessmanager.AccessableObject.zmi_page_request(self, args, kwargs)
     # avoid declarative urls
     path_to_handle = request['URL0'][len(request['BASE0']):]
     path = path_to_handle.split('/')
     if not path[-2] in self.objectIds() \
         and len([x for x in path[:-1] if x.find('.')>0 or x.startswith('manage')])==0:
         new_path = self.absolute_url() + '/' + path[-1]
         if not new_path.endswith(path_to_handle):
             qs = request['QUERY_STRING']
             if qs:
                 new_path += '?' + qs
             request.RESPONSE.redirect(new_path)
Пример #3
0
# init filter from request.
self = zmscontext
REQUEST = request
index = 0
for filterIndex in range(100):
    for filterStereotype in ['attr', 'op', 'value']:
        requestkey = 'filter%s%i' % (filterStereotype, filterIndex)
        sessionkey = '%s_%s' % (requestkey, self.id)
        if REQUEST.get('btn') is None:
            # get value from session
            requestvalue = standard.get_session_value(self, sessionkey, '')
            # set request-value
            REQUEST.set(requestkey, requestvalue)
        else:
            # reset session-value
            standard.set_session_value(self, sessionkey, '')
            # get value from request
            requestvalue = REQUEST.form.get(requestkey, '')
            # reset value
            if REQUEST.get('btn') == 'BTN_RESET':
                requestvalue = ''
            # set request-/session-values for new index
            requestkey = 'filter%s%i' % (filterStereotype, index)
            sessionkey = '%s_%s' % (requestkey, self.id)
            REQUEST.set(requestkey, requestvalue)
            standard.set_session_value(self, sessionkey, requestvalue)
            # increase index
            if filterStereotype == 'value' and requestvalue != '':
                index += 1
request.set('qfilters', index + 1)
standard.set_session_value(zmscontext, 'qfilters_%s' % zmscontext.id,
Пример #4
0
 def recordSet_Filter(self, REQUEST):
     metaObj = self.getMetaobj(self.meta_id)
     res = REQUEST['res']
     # foreign key
     filterattr = 'fk_key'
     filtervalue = 'fk_val'
     sessionattr = '%s_%s' % (filterattr, self.id)
     sessionvalue = '%s_%s' % (filtervalue, self.id)
     standard.set_session_value(
         self, sessionattr,
         REQUEST.form.get(filterattr,
                          standard.get_session_value(self, sessionattr,
                                                     '')))
     standard.set_session_value(
         self, sessionvalue,
         REQUEST.form.get(
             filtervalue,
             standard.get_session_value(self, sessionvalue, '')))
     if REQUEST.get('btn') == 'BTN_RESET':
         standard.set_session_value(self, sessionattr, '')
         standard.set_session_value(self, sessionvalue, '')
     if standard.get_session_value(self,sessionattr, '') != '' and \
        standard.get_session_value(self,sessionvalue, ''):
         res = standard.filter_list(
             res, standard.get_session_value(self, sessionattr),
             standard.get_session_value(self, sessionvalue), '==')
         masterType = [
             x for x in metaObj['attrs'][1:]
             if x['id'] == standard.get_session_value(self, sessionattr)
         ][0]['type']
         master = [
             x for x in self.getParentNode().objectValues(['ZMSCustom'])
             if x.meta_id == masterType
         ][0]
         masterMetaObj = self.getMetaobj(masterType)
         masterAttrs = masterMetaObj['attrs']
         masterRows = master.getObjProperty(masterAttrs[0]['id'], REQUEST)
         masterRows = standard.filter_list(
             masterRows, masterAttrs[1]['id'],
             standard.get_session_value(self, sessionvalue), '==')
         REQUEST.set('masterMetaObj', masterMetaObj)
         REQUEST.set('masterRow', masterRows[0])
     # init filter from request.
     for filterIndex in range(100):
         for filterStereotype in ['attr', 'op', 'value']:
             requestkey = 'filter%s%i' % (filterStereotype, filterIndex)
             sessionkey = '%s_%s' % (requestkey, self.id)
             requestvalue = REQUEST.form.get(
                 requestkey,
                 standard.get_session_value(self, sessionkey, ''))
             if REQUEST.get('btn') == 'BTN_RESET':
                 requestvalue = ''
             REQUEST.set(requestkey, requestvalue)
             standard.set_session_value(self, sessionkey, requestvalue)
     standard.set_session_value(
         self, 'qfilters_%s' % self.id,
         REQUEST.form.get(
             'qfilters',
             standard.get_session_value(self, 'qfilters_%s' % self.id, 1)))
     # apply filter
     for filterIndex in range(100):
         suffix = '%i_%s' % (filterIndex, self.id)
         sessionattr = standard.get_session_value(self,
                                                  'filterattr%s' % suffix,
                                                  '')
         sessionop = standard.get_session_value(self, 'filterop%s' % suffix,
                                                '%')
         sessionvalue = standard.get_session_value(self,
                                                   'filtervalue%s' % suffix,
                                                   '')
         if sessionattr and sessionvalue:
             metaObjAttr = self.getMetaobjAttr(self.meta_id, sessionattr)
             sessionvalue = self.formatObjAttrValue(metaObjAttr,
                                                    sessionvalue,
                                                    REQUEST['lang'])
             res = standard.filter_list(res, sessionattr, sessionvalue,
                                        sessionop)
     REQUEST.set('res', res)
     return res