예제 #1
0
파일: browser.py 프로젝트: wpjunior/proled
 def getMenuLink(self, node):
     """Return the HTML link of the node that is displayed in the menu."""
     obj = node.context
     if zapi.isinstance(obj, Directive):
         ns = zapi.getParent(obj)
         return './'+zapi.name(ns) + '/' + zapi.name(obj) + '/index.html'
     return None
예제 #2
0
def fixupErrorLogging(reg_container, reg):
    # Fix up Error Reporting Service --> Utility 
    # We do this by simply removing old Error Reporting Services and their
    # registrations and then add a new error reporting utility.

    errors = reg.component
    # Set the registration to unregistered and then delete it
    reg.status = InactiveStatus
    del zapi.getParent(reg)[zapi.name(reg)]
    # Get the properties from the old error reporting service and
    # delete it
    props = errors.getProperties()
    folder = zapi.getParent(errors)
    del folder._SampleContainer__data[zapi.name(errors)]
    
    # Only add a new error reporting utility, if there is none.
    if 'ErrorReporting' not in folder:
        # Create the error reporting utility and set its properties
        utility = ErrorReportingUtility()
        utility.setProperties(**props)
        folder['ErrorReporting'] = utility
        # Register the utility and set the registration active
        reg = UtilityRegistration('', IErrorReportingUtility, utility)
        reg_manager = folder.registrationManager
        key = reg_manager.addRegistration(reg)
        reg_manager[key].status = ActiveStatus
    else:
        # If there is one, then at least move the data
        folder['ErrorReporting'].__dict__.update(props)
예제 #3
0
def fixupPrincipalAnnotation(reg_container, reg):
    # Fix up Principal Annotation Service --> Utility 
    ann = reg.component
    # Set the registration to inactive and then delete it
    reg.status = InactiveStatus
    del zapi.getParent(reg)[zapi.name(reg)]
    # Get the instance dictionary from the old principal
    # annotation service and then delete the service
    props = ann.__dict__
    name = zapi.name(ann)
    folder = zapi.getParent(ann)
    del folder._SampleContainer__data[name]
    
    # Only add a new principal annotation utility, if there is none.
    utils = [obj for obj in folder.values()
             if IPrincipalAnnotationUtility.providedBy(obj)]
    if len(utils) == 0:
        # Create the principal annotation utility and set its
        # properties
        utility = PrincipalAnnotationUtility()
        utility.__dict__.update(props)
        folder[name] = utility
        # Register the utility and set the registration active
        reg = UtilityRegistration('', IPrincipalAnnotationUtility,
                                  utility)
        reg_manager = folder.getRegistrationManager() 
        key = reg_manager.addRegistration(reg)
        reg_manager[key].status = ActiveStatus
    else:
        # If there is one, then at least move the data
        utils[0].__dict__.update(props)
예제 #4
0
파일: browser.py 프로젝트: wpjunior/proled
 def getMenuLink(self, node):
     """Return the HTML link of the node that is displayed in the menu."""
     obj = node.context
     if zapi.isinstance(obj, Utility):
         iface = zapi.getParent(obj)
         return "./" + zapi.name(iface) + "/" + zapi.name(obj) + "/index.html"
     if zapi.isinstance(obj, UtilityInterface):
         return "../Interface/" + zapi.name(obj) + "/index.html"
     return None
예제 #5
0
 def delete(self):
     tool = self.activeTool
     regManager = self.context[tool.folder].registrationManager
     names = self.request.form['selected']
     for reg in regManager.values():
         if reg.provided.isOrExtends(tool.interface) and reg.name in names:
             component = reg.component
             reg.status = interfaces.registration.InactiveStatus
             del regManager[zapi.name(reg)]
             del zapi.getParent(component)[zapi.name(component)]
예제 #6
0
파일: browser.py 프로젝트: wpjunior/proled
 def getMenuTitle(self, node):
     """Return the title of the node that is displayed in the menu."""
     obj = node.context
     if zapi.isinstance(obj, UtilityInterface):
         return zapi.name(obj).split(".")[-1]
     if obj.name == NONAME:
         return "no name"
     return obj.name
예제 #7
0
 def registrations(self):
     registered = interfaces.registration.IRegistered(self.context)
     return [
         {'name': zapi.name(reg),
          'url': zapi.absoluteURL(reg, self.request),
          'status': reg.status,
          'details': zapi.queryMultiAdapter((reg, self.request),
                                            name='details')}
         for reg in registered.registrations()]
예제 #8
0
파일: browser.py 프로젝트: wpjunior/proled
 def getMenuTitle(self, node):
     """Return the title of the node that is displayed in the menu."""
     obj = node.context
     if zapi.isinstance(obj, Namespace):
         name = obj.getShortName()
         if name == 'ALL':
             return 'All Namespaces'
         return name
     return zapi.name(obj)
예제 #9
0
파일: browser.py 프로젝트: wpjunior/proled
    def getId(self):
        """Return the id of the field as it is defined for the interface
        utility.

        Example::

          >>> from tests import getInterfaceDetails
          >>> details = getInterfaceDetails()
          >>> details.getId()
          'IFoo'
        """
        return zapi.name(self.context)
예제 #10
0
    def getInputValue(self):
        """See zope.app.form.interfaces.IWidget"""
        field = self.context
        context = field.context
        if interfaces.registration.IRegistration.providedBy(context):
            # It's a registration object. Just get the corresponding attr
            path = getattr(context, field.getName())
        else:
            # It must be a component that is about to be configured.
            # Always return a relative path (just the component name)
            path = zapi.name(context)

        return path
예제 #11
0
파일: tales.py 프로젝트: mleist/ict-ok.org
    def title(self):
        title = None
        if title is None:
            try:
                title = getattr(self.context.getObject(), 'ikName', None)
            except Unauthorized:
                title = None
        if title is None:
            try:
                title = getattr(self.context, 'ikName', None)
            except Unauthorized:
                title = None

        if title is None:
            title = zapi.name(self.context)
        return title or u''
예제 #12
0
    def __call__(self):
        """See zope.app.browser.interfaces.form.IBrowserWidget"""
        # Render as a link to the component
        field = self.context
        context = field.context
        if interfaces.registration.IRegistration.providedBy(context):
            # It's a registration object. Just get the corresponding attr
            component = getattr(context, field.__name__)
            path = zapi.getPath(component)
        else:
            # It must be a component that is about to be configured.
            component = context
            # Always use a relative path (just the component name)
            path = zapi.name(context)

        url = zapi.absoluteURL(component, self.request)

        return ('<a href="%s/@@SelectedManagementView.html">%s</a>'
                % (url, path))
예제 #13
0
파일: module.py 프로젝트: wpjunior/proled
    def getBreadCrumbs(self):
        """Create breadcrumbs for the module path.

        We cannot reuse the the system's bread crumbs, since they go all the
        way up to the root, but we just want to go to the root module."""
        names = self.context.getPath().split('.')
        crumbs = []
        module = self.context
        # I really need the class here, so remove the proxy.
        while removeSecurityProxy(module).__class__ is Module:
            crumbs.append(
                {'name': zapi.name(module),
                 'url': zapi.absoluteURL(module, self.request)}
                )
            module = zapi.getParent(module)

        crumbs.append(
            {'name': _('[top]'),
             'url': zapi.getMultiAdapter(
                      (module, self.request), name='absolute_url')()} )

        crumbs.reverse()
        return crumbs
예제 #14
0
파일: browser.py 프로젝트: wpjunior/proled
 def getMenuLink(self, node):
     """Return the HTML link of the node that is displayed in the menu."""
     return "../Interface/%s/index.html" % zapi.name(node.context)
예제 #15
0
 def title_or_name(self):
     try:
         return getattr(self, 'title', '') or zapi.name(self.context)
     except Unauthorized:
         return zapi.name(self.context)
예제 #16
0
 def name(self):
     return zapi.name(self.context)
예제 #17
0
def evolve(context):
    """Evolve the ZODB from a Zope X3.0 to a X3.1 compatible format.

    - The Principal Annotation Service was replaced by the Principal
      Annotation Utility. Thus all service registrations have to be changed to
      utility registrations. 

    - The Error Reporting Service was replaced by the Error Reporting
      Utility. Thus, all service registrations have to be changed to utility
      registrations. 

    - Component-based registrations used to keep track of their components via
      the component's path. Now it stores the component directly. All
      registrations are updated to this new format.

    - Converts all service registrations to utility registrations providing
      IService, which is the method used to simulate the old service API.

    - Remove 'RegistrationManager' object from all site management folders.

    - Remove all local adapter and utility service instances. 
    """
    root = getRootFolder(context)

    for site in findObjectsProviding(root, ISite):
        sm = site.getSiteManager()

        # Remove old registration manager instances
        for rm in findObjectsProviding(sm, IRegistrationManager):
            # Make sure that we called the new registration manager
            # which will retrieve the old one, if necessary
            zapi.getParent(rm).registrationManager = rm

            # Do a hard core delete, because I want no whining and complaining
            container = zapi.getParent(rm)
            del container._SampleContainer__data[zapi.getName(rm)]

            # Make sure the new registration manager has the correct name:
            rm.__name__ = '++registrations++'
            rm.__parent__ = container

        for reg_container in findObjectsProviding(sm, IRegisterableContainer):
            manager = reg_container.registrationManager

            # Iterate through each registration and fix it up.
            for reg in tuple(manager.values()):

                # Regardless of registration type, we want to convert the
                # component path to component  
                if ('_BBB_componentPath' in reg.__dict__ and
                    reg._BBB_componentPath is not None):

                    reg.component = reg.getComponent()
                    del reg.__dict__['_BBB_componentPath']

                # Fixup and convert service registrations
                if IServiceRegistration.providedBy(reg):
                    if reg.name == 'ErrorLogging':
                        fixupErrorLogging(reg_container, reg)

                    elif reg.name == 'PrincipalAnnotation':
                        fixupPrincipalAnnotation(reg_container, reg)

                    elif reg.name in ('Utilities', 'Adapters'):
                        # Delete the registration
                        reg.status = InactiveStatus
                        del manager[zapi.name(reg)]
                        # Delete the component
                        c = reg.component
                        del zapi.getParent(c)[zapi.name(c)]

                    else:
                        # Handle all outstanding service registrations
                        # Create a new utility registration
                        new_reg = UtilityRegistration(reg.name, IService,
                                                      reg.component)
                        manager.addRegistration(new_reg)
                        new_reg.status = ActiveStatus
                        # Delete the old registration
                        reg.status = InactiveStatus
                        del manager[zapi.getName(reg)]

                # Fixup utility registrations
                else:
                    # Getting the provided interface converts the utility
                    # registration automatically from 'interface' -> 'provided'
                    reg.provided
                    # Now let's reactivate the utility, so it will be
                    # available within the new framework
                    orig = reg.status
                    reg.status = InactiveStatus
                    reg.status = orig
예제 #18
0
 def component(self):
     url = zapi.getMultiAdapter(
         (self.context.component, self.request), name='absolute_url')
     name = zapi.name(self.context.component)
     return {'url': url, 'name': name}