예제 #1
0
    def renderCell(self, item):
        result = []

        if self._browse:
            # XXX this is an override for embedded workspaces, better 
            # solution may be required.
            if item['fullpath']:
                result.append(u'<a href="%s">[%s]</a>' % (
                    item['fullpath'],
                    _(u'browse'),
                ))
            else:
                result.append(u'<a href="%s/%s/%s/%s">[%s]</a>' % (
                    self.table.context.absolute_url(),
                    item['baseview'],
                    item['node'],
                    item['file'],
                    _(u'browse'),
                ))

        if item['permissions'][0] == '-':
            if self._download:
                result.append(u'<a href="%s/@@rawfile/%s/%s">[%s]</a>' % (
                    self.table.context.absolute_url(),
                    item['node'],
                    item['file'],
                    _(u'download'),
                ))

            # XXX *.session.xml assumption
            # XXX make this query some sort of utility or adapter and
            # *.session.xml assumption
            if item['file'].endswith('.session.xml'):
                result.append(u'<a href="%s/@@xmlbase/%s/%s">[%s]</a>' % (
                    self.table.context.absolute_url(),
                    item['node'],
                    item['file'],
                    _(u'run'),
                ))

        return ' '.join(result)
예제 #2
0
파일: converter.py 프로젝트: PMR2/pmr2.app
    def toFieldValue(self, value):
        """\
        As the value could be set with an invalid value that can't be
        looked up, we have to catch that and raise a new exception that
        Field.extract can catch.
        """

        try:
            return super(StorageFileSequenceDataConverter, 
                self).toFieldValue(value)
        except LookupError, err:
            raise FormatterValidationError(_(
                "The selected path is invalid as it does not exist within "
                "this revision."), err)
예제 #3
0
파일: browser.py 프로젝트: PMR2/pmr2.app
    def create(self, data):
        settings = zope.component.getUtility(IPMR2GlobalSettings)
        if settings.workspace_idgen:
            name = settings.workspace_idgen
            idgen = zope.component.queryUtility(IIdGenerator, name=name)
            if idgen is None:
                raise z3c.form.interfaces.ActionExecutionError(
                    ProcessingError(_('Cannot get id generator; please '
                        'contact the repository administrator.')))

            next_id = None
            if next_id in self.context or next_id is None:
                # generate next id
                next_id = idgen.next()
            data['id'] = next_id

        return super(WorkspaceAddForm, self).create(data)
예제 #4
0
파일: browser.py 프로젝트: PMR2/pmr2.app
    def cloneToUserWorkspace(self):
        settings = zope.component.getUtility(IPMR2GlobalSettings)
        target_root = settings.getCurrentUserWorkspaceContainer()

        if settings.workspace_idgen:
            name = settings.workspace_idgen
            idgen = zope.component.queryUtility(IIdGenerator, name=name)
            if idgen is None:
                raise ProcessingError(_('Cannot get id generator; please '
                        'contact the repository administrator.'))
            newid = idgen.next()
        else:
            newid = self._data['id']

        self._newid = newid

        if target_root is None:
            raise ProcessingError('User workspace container not found.')

        # 1. Create workspace object.
        if target_root.get(newid) is not None:
            raise ProcessingError('You already have a workspace with the '
                'same name, please try again with another name.')
        obj = Workspace(newid)
        target_root[newid] = obj
        ctxobj = target_root[newid]
        ctxobj.title = self.context.title
        ctxobj.description = self.context.description
        ctxobj.storage = self.context.storage

        # 2. Create the storage and synchronize it with context.
        utility = zope.component.getUtility(
            IStorageUtility, name=ctxobj.storage)
        utility.create(ctxobj)
        utility.syncWorkspace(ctxobj, self.context)

        ctxobj.reindexObject()

        return ctxobj