Exemplo n.º 1
0
    def _update(self, portal):
        self.log.debug('Changing meeting schema')
        schema_tool = portal.getSchemaTool()
        schema = schema_tool.getSchemaForMetatype(NyMeeting.meta_type)

        try:
            schema.getWidget('auto_register')
        except KeyError:
            pass
        else:
            schema.manage_delObjects([widgetid_from_propname('auto_register')])

        property_schema = get_pluggable_content()[NyMeeting.meta_type][
            'default_schema']['auto_register']
        schema.addWidget('auto_register', **property_schema)

        meetings = portal.getCatalogedObjects(meta_type='Naaya Meeting')
        for meeting in meetings:
            self.log.debug('Found meeting object at %s' %
                           meeting.absolute_url(1))
            if not hasattr(meeting, 'auto_register'):
                meeting.auto_register = False
                self.log.debug(
                    'Added auto_register attribute for meeting at %s' %
                    meeting.absolute_url(1))
        return True
Exemplo n.º 2
0
    def _update(self, portal):
        meta_type = 'Naaya Meeting'
        if not portal.is_pluggable_item_installed(meta_type):
            self.log.debug('Meeting not installed')
            return True

        self.log.debug('Changing meeting schema')
        schema_tool = portal.getSchemaTool()
        schema = schema_tool.getSchemaForMetatype(NyMeeting.meta_type)
        crt_widgets = schema.objectIds()
        if widgetid_from_propname('interval') not in crt_widgets:
            schema.manage_delObjects([widgetid_from_propname('start_date'),
                                      widgetid_from_propname('end_date'),
                                      widgetid_from_propname('time')])
            property_schema = get_pluggable_content()[NyMeeting.meta_type]['default_schema']['interval']
            schema.addWidget('interval', **property_schema)
            self.log.debug(('Naaya Meeting schema changes: '
                            '-start_date -end_date -time +interval'))
        else:
            self.log.debug('Meeting schema already contained interval-property')

        self.log.debug('Patching meeting objects')
        meetings = portal.getCatalogedObjects(meta_type)
        for meeting in meetings:
            if getattr(meeting, 'interval', None) is None:
                self.log.debug('Patching meeting object at %s' %
                               meeting.absolute_url(1))
                time = getattr(meeting, 'time', '')
                start_date = meeting.start_date
                end_date = getattr(meeting, 'end_date', '')
                # old NyMeeting accepted only start_date, interval obj reqs both
                if not end_date:
                    end_date = start_date
                (start_date, end_date) = (start_date.strftime('%d/%m/%Y'),
                                          end_date.strftime('%d/%m/%Y'))

                try:
                    i = interval_from_raw_time(start_date, end_date, time)
                except Exception, e:
                    self.log.error('Can not create Interval: %s' % str(e))
                    try:
                        i = Interval(start_date, '', end_date, '', True)
                    except Exception, e_inner:
                        today = datetime.now().strftime('%d/%m/%Y')
                        i = Interval(today, '', today, '', True)
                        self.log.error('Using TODAY as start/end dates, reason: %s'
                                       % str(e_inner))
                    self.log.error('IMPORTANT: Please manually edit meeting, ' +
                                   ('interval currently set as %s; ' % repr(i))
                                   + ('Old Values: (%s, %s, \'%s\')'
                                    % (start_date, end_date, time)))
                else:
                    self.log.debug(('Successfully converted (%s, %s, \'%s\'), '
                                    % (start_date, end_date, time)) +
                                    'setting meeting.interval: %s' % repr(i))

                meeting.interval = i
                delattr(meeting, 'start_date')
                delattr(meeting, 'end_date')
                delattr(meeting, 'time')
Exemplo n.º 3
0
    def _update(self, portal):
        self.log.debug('Changing meeting schema')
        schema_tool = portal.getSchemaTool()
        schema = schema_tool.getSchemaForMetatype(NyMeeting.meta_type)

        try:
            schema.getWidget('auto_register')
        except KeyError:
            pass
        else:
            schema.manage_delObjects([widgetid_from_propname('auto_register')])

        property_schema = get_pluggable_content()[
            NyMeeting.meta_type]['default_schema']['auto_register']
        schema.addWidget('auto_register', **property_schema)

        meetings = portal.getCatalogedObjects(meta_type='Naaya Meeting')
        for meeting in meetings:
            self.log.debug('Found meeting object at %s' %
                           meeting.absolute_url(1))
            if not hasattr(meeting, 'auto_register'):
                meeting.auto_register = False
                self.log.debug(
                    'Added auto_register attribute for meeting at %s' %
                    meeting.absolute_url(1))
        return True
Exemplo n.º 4
0
 def find_schema_differences(self):
     """
     Searches for schema properties that differ
     from their definition in their content code
     """
     content_types = get_pluggable_content().values()
     portals = get_portals(self)
     missing_properties = {}
     modified_properties = {}
     for portal in portals:
         schema = portal._getOb(ID_SCHEMATOOL, None)
         if schema:
              modified_properties[portal] = self.find_modified_schema_properties(content_types, schema)
              missing_properties[portal] = self.find_missing_schema_properties(content_types, schema)
     return {'missing_properties': missing_properties, 'modified_properties': modified_properties}
Exemplo n.º 5
0
    def add_missing_schema_property(self, property_data, REQUEST=None):
        """ """
        for prop in property_data:
            location = prop.split('||')
            portal = location[0]
            content_type = location[1]
            property = location[2]
            property_schema = get_pluggable_content()[content_type]['default_schema'][property]

            portal = self.unrestrictedTraverse(portal, None)
            schema_tool = portal._getOb(ID_SCHEMATOOL, None)
            schema = schema_tool.getSchemaForMetatype(content_type)
            schema.addWidget(property, **property_schema)

        if REQUEST:
            REQUEST.RESPONSE.redirect('%s/update_schemas_html?find=true' % self.absolute_url())
Exemplo n.º 6
0
    def _update(self, portal):
        meta_type = 'Naaya Meeting'
        NETWORK_NAME = get_zope_env('NETWORK_NAME', '')
        if not portal.is_pluggable_item_installed(meta_type):
            self.log.debug('Meeting not installed')
            return True

        self.log.debug('Changing meeting schema')
        schema_tool = portal.getSchemaTool()
        schema = schema_tool.getSchemaForMetatype(NyMeeting.meta_type)
        crt_widgets = schema.objectIds()
        if widgetid_from_propname('is_eionet_meeting') not in crt_widgets:
            property_schema = get_pluggable_content()[NyMeeting.meta_type][
                'default_schema']['is_eionet_meeting']
            if NETWORK_NAME.lower() != 'eionet':
                property_schema['visible'] = False
            schema.addWidget('is_eionet_meeting', **property_schema)
            self.log.debug(('Naaya Meeting schema changes: '
                            'added the "Eionet Meeting" widget'))
        else:
            self.log.debug(
                'Meeting schema already contained is_eionet_meeting-property')

        return True
Exemplo n.º 7
0
    def _update(self, portal):
        meta_type = 'Naaya Meeting'
        NETWORK_NAME = get_zope_env('NETWORK_NAME', '')
        if not portal.is_pluggable_item_installed(meta_type):
            self.log.debug('Meeting not installed')
            return True

        self.log.debug('Changing meeting schema')
        schema_tool = portal.getSchemaTool()
        schema = schema_tool.getSchemaForMetatype(NyMeeting.meta_type)
        crt_widgets = schema.objectIds()
        if widgetid_from_propname('is_eionet_meeting') not in crt_widgets:
            property_schema = get_pluggable_content()[
                NyMeeting.meta_type]['default_schema']['is_eionet_meeting']
            if NETWORK_NAME.lower() != 'eionet':
                property_schema['visible'] = False
            schema.addWidget('is_eionet_meeting', **property_schema)
            self.log.debug(('Naaya Meeting schema changes: '
                            'added the "Eionet Meeting" widget'))
        else:
            self.log.debug(
                'Meeting schema already contained is_eionet_meeting-property')

        return True
def _list_content_types():
    for content_type in get_pluggable_content().values():
        if content_type.get('_class', None) is None:
            continue
        yield content_type
Exemplo n.º 9
0
    def _update(self, portal):
        meta_type = 'Naaya Meeting'
        if not portal.is_pluggable_item_installed(meta_type):
            self.log.debug('Meeting not installed')
            return True

        self.log.debug('Changing meeting schema')
        schema_tool = portal.getSchemaTool()
        schema = schema_tool.getSchemaForMetatype(NyMeeting.meta_type)
        crt_widgets = schema.objectIds()
        if widgetid_from_propname('interval') not in crt_widgets:
            schema.manage_delObjects([
                widgetid_from_propname('start_date'),
                widgetid_from_propname('end_date'),
                widgetid_from_propname('time')
            ])
            property_schema = get_pluggable_content()[
                NyMeeting.meta_type]['default_schema']['interval']
            schema.addWidget('interval', **property_schema)
            self.log.debug(('Naaya Meeting schema changes: '
                            '-start_date -end_date -time +interval'))
        else:
            self.log.debug(
                'Meeting schema already contained interval-property')

        self.log.debug('Patching meeting objects')
        meetings = portal.getCatalogedObjects(meta_type)
        for meeting in meetings:
            if getattr(meeting, 'interval', None) is None:
                self.log.debug('Patching meeting object at %s' %
                               meeting.absolute_url(1))
                time = getattr(meeting, 'time', '')
                start_date = meeting.start_date
                end_date = getattr(meeting, 'end_date', '')
                # old NyMeeting accepted only start_date, interval obj
                # requires both
                if not end_date:
                    end_date = start_date
                (start_date, end_date) = (start_date.strftime('%d/%m/%Y'),
                                          end_date.strftime('%d/%m/%Y'))

                try:
                    i = interval_from_raw_time(start_date, end_date, time)
                except Exception, e:
                    self.log.error('Can not create Interval: %s' % str(e))
                    try:
                        i = Interval(start_date, '', end_date, '', True)
                    except Exception, e_inner:
                        today = datetime.now().strftime('%d/%m/%Y')
                        i = Interval(today, '', today, '', True)
                        self.log.error(
                            'Using TODAY as start/end dates, reason: %s' %
                            str(e_inner))
                    self.log.error(
                        'IMPORTANT: Please manually edit meeting, ' +
                        ('interval currently set as %s; ' % repr(i)) +
                        ('Old Values: (%s, %s, \'%s\')' %
                         (start_date, end_date, time)))
                else:
                    self.log.debug(
                        ('Successfully converted (%s, %s, \'%s\'), ' %
                         (start_date, end_date, time)) +
                        'setting meeting.interval: %s' % repr(i))

                meeting.interval = i
                delattr(meeting, 'start_date')
                delattr(meeting, 'end_date')
                delattr(meeting, 'time')
def _list_content_types():
    for content_type in get_pluggable_content().values():
        if content_type.get('_class', None) is None:
            continue
        yield content_type