예제 #1
0
def object_description_sentence( objid, type, director):
    """given an object's id, return a sentence describing
    the object.
    
    In case the id is empty, return a sentence saying
    the object is not yet created, please create it.
    
    In case the id is valid, return a sentence describing
    the object, and a link to configure the object.
    """
    if objid == '':
        link = action_link(
            actionRequireAuthentication(
            type.lower(), director.sentry,
            label = 'create', routine = 'new',
            ), director.cgihome)
        obj_ctrl = "%s has not been defined. Please %s a %s" % (
            type, link, type.lower())
    else:
        link = action_link(
            actionRequireAuthentication(
            type.lower(), director.sentry,
            label = 'configure', routine = 'new',
            ), director.cgihome)
        method = 'get%s' % type
        method = getattr( director.clerk, method )
        obj_record = method( objid )
        obj_ctrl = "%s (%s)" % (
            obj_record.short_description, link)
        pass
    return obj_ctrl
class NeutronExperiment(base):


    class Inventory(base.Inventory):

        import pyre.inventory

        id = pyre.inventory.str("id", default=None)
        id.meta['tip'] = "the unique identifier of the experiment"

        ncount = pyre.inventory.float( 'ncount', default = 1e6 )
        ncount.meta['tip'] = 'number of neutrons'

        pass # end of Inventory


    def default(self, director):
        try:
            page = director.retrieveSecurePage( 'neutronexperiment' )
        except AuthenticationError, err:
            return err.page
        
        main = page._body._content._main

        # populate the main column
        document = main.document(title='Neutron Experiment')
        document.description = ''
        document.byline = 'byline?'

        p = document.paragraph()
        action = actionRequireAuthentication(
            actor = 'neutronexperimentwizard', sentry = director.sentry,
            label = 'this wizard', routine = 'start',
            )
        wizard_link = action_link( action, director.cgihome )        

        action = actionRequireAuthentication(
            actor = 'neutronexperiment', sentry = director.sentry,
            label = 'experiments', routine = 'listall',
            )
        list_link = action_link( action, director.cgihome )        

        p.text = [
            'In this virtual neutron facility, you can set up',
            'a new experiment by using %s.' % wizard_link,
            'Or you can select from one of the %s you have run' % list_link,
            'and rerun it with new settings.',
            ]
            
        return page
    def listall(self, director):
        page = director.retrievePage('scatteringKernel')
        
        main = page._body._content._main
        
        # populate the main column
        document = main.document(title='List of scattering kernels')
        document.description = ''
        document.byline = 'byline?'

        # retrieve id:record dictionary from db
        clerk = director.clerk
        scatteringKernels = clerk.indexScatteringKernels().values()
        scatteringKernels = [ clerk.getHierarchy(scatteringKernel) for scatteringKernel in scatteringKernels]
            
        p = document.paragraph()
        numScatteringKernels = len(scatteringKernels)
        columns = ['id', 'reference', 'short_description', 'type', 'creator', 'date' ]
        columnTitles = ['Short description', 'Type of scattering kernel', 'Creator', 'Date of creation']

        from PyHtmlTable import PyHtmlTable
        t = PyHtmlTable(numScatteringKernels, len(columnTitles), {'width':'400','border':2})#,'bgcolor':'white'})
        for colNum, col in enumerate(columnTitles):
            t.setc(0,colNum,col)
            
        for row, sk in enumerate(scatteringKernels):
            for colNum, colName in enumerate( columns[2:] ):           
                value = sk.getColumnValue(colName)
                if colName == 'short_description':
                    link = action_link(
                        actionRequireAuthentication(
                        'scatteringKernel',
                        director.sentry,
                        label = value,
                        routine = 'show',
                        id = sk.id,
                        ),  director.cgihome
                        )
                    value = link
                t.setc(row+1,colNum,value)
        p.text = [t.return_html()]
        
        p = document.paragraph()
        p.text = [action_link(
        actionRequireAuthentication(
        'scatteringKernelInput', director.sentry,
        label = 'Add a new scattering kernel'),  director.cgihome
        ),
        '<br>']
        return page          
예제 #4
0
class ScatteringKernelInput(base):

#    @staticmethod
    def default(self, director):
        try:
            page, document = self._head( director )
        except AuthenticationError, err:
            return err.page
        formcomponent = self.retrieveFormToShow( 'selectkernel')
        formcomponent.director = director
        # build the SKChoice form
        SKChoice = document.form(name='scatteringKernelInput', action=director.cgihome)
        # specify action
        action = actionRequireAuthentication(          
            actor = 'scatteringKernelInput', 
            sentry = director.sentry,
            routine = 'onSelect',
            label = '',
            arguments = {'form-received': formcomponent.name },
            )
        from vnf.weaver import action_formfields
        action_formfields( action, SKChoice )
        # expand the form with fields of the data object that is being edited
        formcomponent.expand( SKChoice )
        submit = SKChoice.control(name='submit',type="submit", value="next")
        return page 
def list( container, document, actor, director,
          routines = ['edit'] ):
    p = document.paragraph()

    formatstr = '%(index)s: %(name)s '
    formatstr += ' '.join(
        [ '(%'+'(%slink)s)' % routine for routine in routines ]
        )

    for i, element in enumerate( container ):
        
        p = document.paragraph()

        subs = {'name': element.short_description,
                'index': i+1}
        
        #links
        for routine in routines:
            link = action_link(
                actionRequireAuthentication(
                actor, director.sentry,
                routine = routine,
                label = routine,
                id = element.id,
                ),  director.cgihome
                )
            subs[ '%slink' % routine ] = link
            continue

        p.text += [
            formatstr % subs,
            ]
        continue
    return
예제 #6
0
    def listall(self, director):
        page = director.retrievePage( 'job' )
        
        main = page._body._content._main
        
        # populate the main column
        document = main.document(title='List of computational jobs')
        document.description = ''
        document.byline = 'byline?'

        # retrieve id:record dictionary from db
        clerk = director.clerk
        jobs = clerk.getJobs( where = 'owner=%r' % director.sentry.username )
            
        p = document.paragraph()

        numJobs = len(jobs)

        columns = [
            'jobName', 'id', 'owner', 'server',
            'numprocessors', 'status', 'timeStart', 'timeCompletion',
            ]
        numColumns=len(columns)

        from PyHtmlTable import PyHtmlTable
        t=PyHtmlTable(numJobs,numColumns, {'width':'400','border':2,'bgcolor':'white'})
        for colNum, col in enumerate(columns):
            t.setc(0,colNum,col)
            continue
        
        for row, job in enumerate( jobs ):
            for colNum, colName in enumerate( columns ):
                
                value = job.getColumnValue(colName)
                if colName == 'jobName':
                    link = action_link(
                        actionRequireAuthentication(
                        'job',
                        director.sentry,
                        label = value,
                        routine = 'show',
                        id = job.id,
                        ),  director.cgihome
                        )
                    value = link
                    pass # endif
                        
                t.setc(row+1,colNum,value)
                #colNum+=1
        p.text = [t.return_html()]
        
        return page
 def _add_delete_sentence(self, document, director):
     p = document.paragraph()
     action = actionRequireAuthentication(
         label = 'here',
         actor = 'neutronexperiment',
         routine = 'delete',
         sentry = director.sentry,
         id = self.inventory.id)
     link = action_link( action, director.cgihome )
     p.text = [
         'To delete this experiment, please click %s.' % link,
         ]
     return
 def _add_run_sentence(self, document, director):
     p = document.paragraph()
     action = actionRequireAuthentication(
         label = 'here',
         actor = 'neutronexperiment',
         routine = 'run',
         sentry = director.sentry,
         id = self.inventory.id)
     link = action_link( action, director.cgihome )
     p.text = [
         'If you are done with experiment configuration,',
         'please click %s to start this experiment.' % link,
         ]
     return
 def _add_revision_sentence(self, document, director):
     p = document.paragraph()
     action = actionRequireAuthentication(
         label = 'here',
         actor = 'neutronexperimentwizard',
         routine = 'start',
         sentry = director.sentry,
         id = self.inventory.id)
     link = action_link( action, director.cgihome )
     p.text = [
         'If you need to make changes to this experiment,',
         'please click %s.' % link,
         ]
     return
예제 #10
0
    def _footer(self, document, director):
        #
        document.paragraph()

        p = document.paragraph(align='right')
        action = actionRequireAuthentication(label='Cancel',
                                             actor='neutronexperimentwizard',
                                             routine='cancel',
                                             id=self.inventory.id,
                                             sentry=director.sentry)
        link = action_link(action, director.cgihome)
        p.text = [
            '%s this experiment planning.' % link,
        ]
        return
    def _footer(self, document, director):
        #
        document.paragraph()

        p = document.paragraph(align = 'right')
        action = actionRequireAuthentication(
            label = 'Cancel',
            actor = 'neutronexperimentwizard',
            routine = 'cancel',
            id = self.inventory.id,
            sentry = director.sentry)
        link = action_link( action, director.cgihome )
        p.text = [
            '%s this experiment planning.' % link,
            ]
        return
예제 #12
0
def noscatterer(document, director):
    p = document.paragraph()

    link = action_link(
        actionRequireAuthentication(
            'scatterer',
            director.sentry,
            label='add',
            routine='new',
        ), director.cgihome)

    p.text = [
        "There is no scatterer in this sample assembly. ",
        'Please %s a scatter.' % (director.cgihome, link)
    ]
    return
예제 #13
0
def noscatterer( document, director ):
    p = document.paragraph()

    link = action_link(
        actionRequireAuthentication(
        'scatterer', director.sentry,
        label = 'add', routine = 'new',
        ),  director.cgihome
        )
    
    p.text = [
        "There is no scatterer. ",
        'Please %s a scatter.' % (
        director.cgihome, link)
        ]
    return
예제 #14
0
class SampleInput(FormActor):
    class Inventory(FormActor.Inventory):

        import pyre.inventory

        id = pyre.inventory.str("id", default=None)
        id.meta['tip'] = "the unique identifier for a given search"

        page = pyre.inventory.str('page', default='empty')

    def default(self, director):
        return self.inputMaterial(director)

    def inputMaterial(self, director):
        try:
            page = director.retrievePage('sampleInput')
        except AuthenticationError, err:
            return err.page
#        experiment = director.clerk.getNeutronExperiment(self.inventory.id)
        main = page._body._content._main
        # populate the main column
        document = main.document(title='Sample input')
        document.description = ''
        document.byline = '<a href="http://danse.us">DANSE</a>'

        formcomponent = self.retrieveFormToShow('inputMaterial')
        formcomponent.director = director
        # build the form
        form = document.form(name='', action=director.cgihome)
        # specify action
        action = actionRequireAuthentication(
            actor='sampleInput',
            sentry=director.sentry,
            routine='selectShape',
            label='',
            id=self.inventory.id,
            arguments={'form-received': formcomponent.name},
        )
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)
        submit = form.control(name='submit', type="submit", value="next")
        #self.processFormInputs(director)
        return page
예제 #15
0
    def listall(self, director):
        page = director.retrievePage('job')

        main = page._body._content._main

        # populate the main column
        document = main.document(title='List of computational jobs')
        document.description = ''
        document.byline = 'byline?'

        # retrieve id:record dictionary from db
        clerk = director.clerk
        jobs = clerk.getJobs(where='owner=%r' % director.sentry.username)

        p = document.paragraph()

        numJobs = len(jobs)

        columns = [
            'jobName',
            'id',
            'owner',
            'server',
            'numprocessors',
            'status',
            'timeStart',
            'timeCompletion',
        ]
        numColumns = len(columns)

        from PyHtmlTable import PyHtmlTable
        t = PyHtmlTable(numJobs, numColumns, {
            'width': '400',
            'border': 2,
            'bgcolor': 'white'
        })
        for colNum, col in enumerate(columns):
            t.setc(0, colNum, col)
            continue

        for row, job in enumerate(jobs):
            for colNum, colName in enumerate(columns):

                value = job.getColumnValue(colName)
                if colName == 'jobName':
                    link = action_link(
                        actionRequireAuthentication(
                            'job',
                            director.sentry,
                            label=value,
                            routine='show',
                            id=job.id,
                        ), director.cgihome)
                    value = link
                    pass  # endif

                t.setc(row + 1, colNum, value)
                #colNum+=1
        p.text = [t.return_html()]

        return page
예제 #16
0
class Job(base):
    class Inventory(base.Inventory):

        import time
        import pyre.inventory

        id = pyre.inventory.str("id", default=None)
        id.meta['tip'] = "the unique identifier for a given search"

    def default(self, director):
        return self.listall(director)

    def listall(self, director):
        page = director.retrievePage('job')

        main = page._body._content._main

        # populate the main column
        document = main.document(title='List of computational jobs')
        document.description = ''
        document.byline = 'byline?'

        # retrieve id:record dictionary from db
        clerk = director.clerk
        jobs = clerk.getJobs(where='owner=%r' % director.sentry.username)

        p = document.paragraph()

        numJobs = len(jobs)

        columns = [
            'jobName',
            'id',
            'owner',
            'server',
            'numprocessors',
            'status',
            'timeStart',
            'timeCompletion',
        ]
        numColumns = len(columns)

        from PyHtmlTable import PyHtmlTable
        t = PyHtmlTable(numJobs, numColumns, {
            'width': '400',
            'border': 2,
            'bgcolor': 'white'
        })
        for colNum, col in enumerate(columns):
            t.setc(0, colNum, col)
            continue

        for row, job in enumerate(jobs):
            for colNum, colName in enumerate(columns):

                value = job.getColumnValue(colName)
                if colName == 'jobName':
                    link = action_link(
                        actionRequireAuthentication(
                            'job',
                            director.sentry,
                            label=value,
                            routine='show',
                            id=job.id,
                        ), director.cgihome)
                    value = link
                    pass  # endif

                t.setc(row + 1, colNum, value)
                #colNum+=1
        p.text = [t.return_html()]

        return page

    def edit(self, director):
        try:
            page = director.retrieveSecurePage('job')
        except AuthenticationError, err:
            return err.page

        main = page._body._content._main

        job = self.processFormInputs(director)
        if job is None:  # input is not from form
            job = director.clerk.getJob(self.inventory.id)
            pass  # endif

        document = main.document(title='Job editor')

        formcomponent = self.retrieveFormToShow('job')
        formcomponent.inventory.id = job.id
        formcomponent.director = director

        form = document.form(name='job',
                             legend=formcomponent.legend(),
                             action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(
            actor='job',
            sentry=director.sentry,
            label='',
            routine='submit',
            arguments={'form-received': formcomponent.name})
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)

        submit = form.control(name="submit", type="submit", value="Submit")

        return page
예제 #17
0
        id = self.inventory.id
        record = director.clerk.getJob(id)
        assert record.owner == director.sentry.username

        main = page._body._content._main
        document = main.document(title='Job # %s: %s' %
                                 (record.id, record.status))

        if record.status == 'created':
            p = document.paragraph()
            link = action_link(
                actionRequireAuthentication(
                    'job',
                    director.sentry,
                    label='submit',
                    routine='edit',
                    id=record.id,
                ), director.cgihome)

            p.text = [
                'This job is created but not submitted.',
                'Please %s it first' % link,
            ]
            return page

        if record.status not in ['created', 'finished']:
            status = check(record, director)

        props = record.getColumnNames()
        lines = ['%s=%s' % (prop, getattr(record, prop)) for prop in props]
            page = director.retrieveSecurePage( 'sampleassembly' )
        except AuthenticationError, err:
            return err.page
        
        main = page._body._content._main

        # populate the main column
        document = main.document(title='List of sample assemblies')
        document.description = ''
        document.byline = 'byline?'

        p = document.paragraph()
        link = action_link(
            actionRequireAuthentication(
                'sampleassembly',
                director.sentry,
                label = 'link',
                routine = 'new',
                ),  director.cgihome
            )
        p.text = [
            'To create a new sample assembly, please use this %s' % link
            ]

        p = document.paragraph()
        p = document.paragraph()

        # retrieve id:record dictionary from db
        clerk = director.clerk
        sampleassemblies = clerk.indexSampleAssemblies()
        
        listsampleassemblies( sampleassemblies.values(), document, director )
예제 #19
0
        document.byline = 'byline?'

        formcomponent = self.retrieveFormToShow('selectneutroninstrument')
        formcomponent.inventory.experiment_id = self.inventory.id
        formcomponent.director = director

        # create form
        form = document.form(name='selectneutroninstrument',
                             legend=formcomponent.legend(),
                             action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(
            actor='neutronexperimentwizard',
            sentry=director.sentry,
            label='',
            routine='configure_instrument',
            id=self.inventory.id,
            arguments={'form-received': formcomponent.name})
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)

        # run button
        submit = form.control(name="submit", type="submit", value="Continue")

        #        self._footer( document, director )
        return page
예제 #20
0
    def listall(self, director):
        page = director.retrievePage('sample')

        main = page._body._content._main

        # populate the main column
        document = main.document(title='List of samples')
        document.description = ''
        document.byline = 'byline'

        # retrieve id:record dictionary from db
        clerk = director.clerk
        scatterers = clerk.indexScatterers(where='template=True').values()
        scatterers = [
            clerk.getHierarchy(scatterer) for scatterer in scatterers
        ]
        samples = scatterers

        p = document.paragraph()
        import operator
        generators = [
            operator.attrgetter('short_description'),
            lambda s: s.matter.realmatter.chemical_formula,
            lambda s: format_lattice_parameters(s.matter.realmatter),
            lambda s: format_atoms(s.matter.realmatter),
            lambda s: format_shape(s.shape.realshape),
        ]

        columnTitles = [
            'Sample description', 'Chemical formula', 'Cartesian lattice',
            'Atom positions', 'Shape'
        ]

        t = PyHtmlTable(len(samples), len(columnTitles), {
            'width': '90%',
            'border': 2,
            'bgcolor': 'white'
        })
        # first row for labels
        for colNum, col in enumerate(columnTitles):
            t.setc(0, colNum, col)

        # other rows for values
        for row, sample in enumerate(samples):
            #first put in the radio button
            #selection = "<input type='radio' name='actor.form-received.kernel_id' value="+sample.id+" id='radio'/>"
            #t.setc(row+1, 0, selection)
            for colNum, generator in enumerate(generators):
                value = generator(sample)
                t.setc(row + 1, colNum, value)

        p.text = [t.return_html()]

        p = document.paragraph()
        p.text = [
            action_link(
                actionRequireAuthentication('sampleInput',
                                            director.sentry,
                                            label='Add a new sample',
                                            routine='default'),
                director.cgihome), '<br>'
        ]

        return page
예제 #21
0
        
        id = self.inventory.id
        record = director.clerk.getJob( id )
        assert record.owner == director.sentry.username

        main = page._body._content._main
        document = main.document( title = 'Job # %s: %s' % (
            record.id, record.status ) )

        if record.status == 'created':
            p = document.paragraph()
            link = action_link(
                actionRequireAuthentication(
                'job',
                director.sentry,
                label = 'submit',
                routine = 'edit',
                id = record.id,
                ),  director.cgihome
                )
            
            p.text = [
                'This job is created but not submitted.',
                'Please %s it first' % link,
                ]
            return page
            
        if record.status not in ['created', 'finished']:
            status = check( record, director )

        props = record.getColumnNames()
예제 #22
0
         page = director.retrieveSecurePage( 'scatteringKernelInput' )
     except AuthenticationError, err:
         return err.page
     main = page._body._content._main
     document = main.document(title="")
     document.byline = '<a href="http://danse.us">DANSE</a>'
     
     formcomponent = self.retrieveFormToShow( 'gulp')
     formcomponent.director = director
     # build the SKChoice form
     form = document.form(name='scatteringKernelInput', action=director.cgihome)
     # specify action
     action = actionRequireAuthentication(          
         actor = 'job', 
         sentry = director.sentry,
         routine = 'edit',
         label = '',
         arguments = {'form-received': formcomponent.name },
         )
     from vnf.weaver import action_formfields
     action_formfields( action, form )
     # expand the form with fields of the data object that is being edited
     formcomponent.expand( form )
     submit = form.control(name='submit',type="submit", value="next")
     return page 
 
 def localOrbitalHarmonic(self, director):
     try:
         page = director.retrieveSecurePage( 'scatteringKernelInput' )
     except AuthenticationError, err:
         return err.page
def listexperiments( experiments, document, director ):
    p = document.paragraph()

    n = len(experiments)

    p.text = [ 'Here is a list of experiments you have planned or run:' ]


    formatstr = '%(index)s: %(viewlink)s (%(status)s) is a measurement of %(sample)r in %(instrument)r (%(deletelink)s)'
    actor = 'neutronexperiment'
    container = experiments

    for i, element in enumerate( container ):
        
        p = document.paragraph()
        name = element.short_description
        if name in ['', None, 'None'] : name = 'undefined'
        action = actionRequireAuthentication(
            actor, director.sentry,
            routine = 'view',
            label = name,
            id = element.id,
            )
        viewlink = action_link( action,  director.cgihome )

        action = actionRequireAuthentication(
            actor, director.sentry,
            routine = 'delete',
            label = 'delete',
            id = element.id,
            )
        deletelink = action_link( action,  director.cgihome )

        element = director.clerk.getHierarchy( element )
        if element.instrument is None \
               or element.instrument.instrument is None:
            action = actionRequireAuthentication(
                'neutronexperimentwizard', sentry = director.sentry,
                label = 'select instrument',
                routine = 'select_instrument',
                id = element.id,
                )
            link = action_link( action, director.cgihome )
            instrument = link
        else:
            instrument = element.instrument.instrument
            instrument = instrument.short_description
            pass # end if
        
        subs = {'index': i+1,
                'viewlink': viewlink,
                'deletelink': deletelink,
                'status': element.status,
                'instrument': instrument,
                'sample': 'sample',
                }

        p.text += [
            formatstr % subs,
            ]
        continue
    return
예제 #24
0
            page = director.retrieveSecurePage('sampleassembly')
        except AuthenticationError, err:
            return err.page

        main = page._body._content._main

        # populate the main column
        document = main.document(title='List of sample assemblies')
        document.description = ''
        document.byline = 'byline?'

        p = document.paragraph()
        link = action_link(
            actionRequireAuthentication(
                'sampleassembly',
                director.sentry,
                label='link',
                routine='new',
            ), director.cgihome)
        p.text = ['To create a new sample assembly, please use this %s' % link]

        p = document.paragraph()
        p = document.paragraph()

        # retrieve id:record dictionary from db
        clerk = director.clerk
        sampleassemblies = clerk.indexSampleAssemblies()

        listsampleassemblies(sampleassemblies.values(), document, director)

        return page
예제 #25
0
class Greeter(Actor):
    class Inventory(Actor.Inventory):

        import pyre.inventory

    def default(self, director):
        try:
            page = director.retrieveSecurePage('greet')
        except AuthenticationError, error:
            return error.page

        main = page._body._content._main

        # populate the main column
        username = director.sentry.username
        userrecord = director.clerk.getUser(username)
        fullname = userrecord.fullname
        title = 'Welcome to the Virtual Neutron Facility, %s!' % (fullname, ),
        document = main.document(title=title)

        p = document.paragraph()
        action = actionRequireAuthentication(
            actor='neutronexperiment',
            sentry=director.sentry,
            label='run virtual neutron experiments',
            routine='default',
        )
        link = action_link(action, director.cgihome)
        p.text = [
            'In this web service facility, you can %s. ' % link,
            'In a virtual neutron experiment, ',
            'virtual neutrons are generated from a virtual neutron moderator,',
            'guided by virtual neutron guides,',
            'scattered by a virtual sample and sample environment,',
            'and intercepted by detectors.',
        ]

        p = document.paragraph()
        action = actionRequireAuthentication(
            actor='instrument',
            sentry=director.sentry,
            label='neutron instruments',
            routine='listall',
        )
        link = action_link(action, director.cgihome)
        p.text = [
            'You can do your experiments on a variety of %s,' % link,
            'both actual physical instruments and conceptual, nonphysical instruments'
        ]

        p = document.paragraph()
        action = actionRequireAuthentication(
            actor='scatteringKernel',
            sentry=director.sentry,
            label='scattering kernels',
            routine='default',
        )
        link = action_link(action, director.cgihome)
        p.text = [
            'You can also create your sample and predict its neutron',
            'scattering properties by calculating its structure or dynamics.',
            'For example, the material behaviors calculated by ab initio',
            'or molecular dynamics methods become',
            '%s that can be used in the sample simulation' % link,
            'part of your virtual experiment.',
        ]

        p = document.paragraph()
        p.text = [
            'On the left, several menu items link to a variety of',
            'functions.',
            'You can review past experiments by clicking "Experiments",',
            'or browse your personal library of sample assemblies by',
            'clicking "Sample Assemblies".',
            'Neutron instruments in which you can run your experiments',
            'are accessible through "Instruments".',
            'When you start a virtual experiment, or a material',
            'simulation, they became jobs submitted to computing',
            'resources. You can monitor their progress by clicking',
            '"Jobs".',
        ]

        p = document.paragraph()
        email = '<a href="mailto:[email protected]">us</a>'
        p.text = [
            'We welcome your comments on this web service, ',
            'suggestions for new features, and reports of',
            'discrepancies or bugs.'
        ]

        return page
        document.byline = 'byline?'

        formcomponent = self.retrieveFormToShow( 'selectneutroninstrument' )
        formcomponent.inventory.experiment_id = self.inventory.id
        formcomponent.director = director
        
        # create form
        form = document.form(
            name='selectneutroninstrument',
            legend= formcomponent.legend(),
            action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(
            actor = 'neutronexperimentwizard', sentry = director.sentry,
            label = '', routine = 'configure_instrument',
            id = self.inventory.id,
            arguments = {'form-received': formcomponent.name } )
        from vnf.weaver import action_formfields
        action_formfields( action, form )

        # expand the form with fields of the data object that is being edited
        formcomponent.expand( form )

        # run button
        submit = form.control(name="submit", type="submit", value="Continue")
            
#        self._footer( document, director )
        return page

예제 #27
0
    def listall(self, director):
        page = director.retrievePage('scatteringKernel')

        main = page._body._content._main

        # populate the main column
        document = main.document(title='List of scattering kernels')
        document.description = ''
        document.byline = 'byline?'

        # retrieve id:record dictionary from db
        clerk = director.clerk
        scatteringKernels = clerk.indexScatteringKernels().values()
        scatteringKernels = [
            clerk.getHierarchy(scatteringKernel)
            for scatteringKernel in scatteringKernels
        ]

        p = document.paragraph()
        numScatteringKernels = len(scatteringKernels)
        columns = [
            'id', 'reference', 'short_description', 'type', 'creator', 'date'
        ]
        columnTitles = [
            'Short description', 'Type of scattering kernel', 'Creator',
            'Date of creation'
        ]

        from PyHtmlTable import PyHtmlTable
        t = PyHtmlTable(numScatteringKernels, len(columnTitles), {
            'width': '400',
            'border': 2
        })  #,'bgcolor':'white'})
        for colNum, col in enumerate(columnTitles):
            t.setc(0, colNum, col)

        for row, sk in enumerate(scatteringKernels):
            for colNum, colName in enumerate(columns[2:]):
                value = sk.getColumnValue(colName)
                if colName == 'short_description':
                    link = action_link(
                        actionRequireAuthentication(
                            'scatteringKernel',
                            director.sentry,
                            label=value,
                            routine='show',
                            id=sk.id,
                        ), director.cgihome)
                    value = link
                t.setc(row + 1, colNum, value)
        p.text = [t.return_html()]

        p = document.paragraph()
        p.text = [
            action_link(
                actionRequireAuthentication(
                    'scatteringKernelInput',
                    director.sentry,
                    label='Add a new scattering kernel'), director.cgihome),
            '<br>'
        ]
        return page
        try:
            page = director.retrieveSecurePage('sampleassembly')
        except AuthenticationError, err:
            return err.page

        id = self.inventory.id
        record = director.clerk.getSampleAssembly(id)
        record = director.getHierarchy(record)
        scatterers = record.scatterers

        for scatterer in scatterers:
            p = document.paragraph()
            link = action_link(
                actionRequireAuthentication(
                    'scatterer',
                    director.sentry,
                    routine='addscatterer',
                    label='add',
                ), director.cgihome)
            continue

        p = document.paragraph()
        link = action_link(
            actionRequireAuthentication(
                'sampleassemblywizard',
                director.sentry,
                routine='addscatterer',
                label='add',
            ), director.cgihome)
        p.text = [
            'There is no scatterer in sample assembly at this moment. ',
            'Please %s a scatterer.' % link,
class SampleAssemblyWizard(base):
    class Inventory(base.Inventory):

        import pyre.inventory

        id = pyre.inventory.str('id', default='')

        pass  # end of Inventory

    def default(self, director):
        return self.new(director)

    def new(self, director):
        'new sample assembly. wizard step 1'
        try:
            page = director.retrieveSecurePage('sampleassembly')
        except AuthenticationError, err:
            return err.page

        record = new_sampleassembly(director)

        main = page._body._content._main

        # populate the main column
        document = main.document(title='Sample Assembly Builder')
        document.description = (
            'A sample assembly is a collection of neutron scatterers. '\
            'For example, it can consist of a main sample, '\
            'a sample container, and a furnace.\n'\
            )
        document.byline = 'byline?'

        # form
        formcomponent = self.retrieveFormToShow('sampleassembly')
        formcomponent.inventory.id = record.id
        formcomponent.director = director

        form = document.form(name='sampleassembly',
                             legend=formcomponent.legend(),
                             action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(actor='sampleassemblywizard',
                                             sentry=director.sentry,
                                             label='',
                                             routine='new1',
                                             arguments={
                                                 'id':
                                                 record.id,
                                                 'form-received':
                                                 formcomponent.name
                                             })
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)

        # ok button
        submit = form.control(name="submit", type="submit", value="next")

        return page
예제 #30
0
        #
        # create form
        formcomponent = self.retrieveFormToShow( 'selectshapetype' )
        formcomponent.inventory.id = shape.id
        formcomponent.director = director
        
        form = document.form(
            name='selectshapetype',
            legend= formcomponent.legend(),
            action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(
            actor = 'scatterer', sentry = director.sentry,
            label = '',
            routine = 'editshape',
            arguments = { 'id': self.inventory.id,
                          'form-received': formcomponent.name } )
        from vnf.weaver import action_formfields
        action_formfields( action, form )

        # expand the form with fields of the data object that is being edited
        formcomponent.expand( form )

        # ok button
        submit = form.control(name="submit", type="submit", value="OK")
        
        return page


    def editshape(self, director):
예제 #31
0
        # start document
        main = page._body._content._main
        document = self._document(main, director)
        self._tree(document, director)

        # create form
        form = document.form(name='instrument',
                             legend=formcomponent.legend(),
                             action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(actor='instrument',
                                             sentry=director.sentry,
                                             label='',
                                             routine='set',
                                             arguments={
                                                 'id':
                                                 self.inventory.id,
                                                 'form-received':
                                                 formcomponent.name
                                             })
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)

        # ok button
        submit = form.control(name="submit", type="submit", value="OK")

        return page
            page = director.retrieveSecurePage( 'neutronexperiment' )
        except AuthenticationError, err:
            return err.page
        
        main = page._body._content._main

        # populate the main column
        document = main.document(title='Experiments')
        document.description = ''
        document.byline = 'byline?'

        #
        p = document.paragraph()
        action = actionRequireAuthentication(
            label = 'this wizard',
            actor = 'neutronexperimentwizard',
            routine = 'start',
            sentry = director.sentry,
            )
        link = action_link( action, director.cgihome )
        p.text = [
            'You can perform various kinds of neutron experiments in',
            'this virtual neutron facility.',
            'To start, you can plan a new experiment by following %s.' % link,
            ]

        # retrieve id:record dictionary from db
        clerk = director.clerk
        experiments = clerk.indexNeutronExperiments()
        # make a list of all experiments
        listexperiments( experiments.values(), document, director )
        return page
        try:
            page = director.retrieveSecurePage( 'sampleassembly' )
        except AuthenticationError, err:
            return err.page

        id = self.inventory.id
        record = director.clerk.getSampleAssembly( id )
        record = director.getHierarchy( record )
        scatterers = record.scatterers

        for scatterer in scatterers:
            p = document.paragraph()
            link = action_link(
                actionRequireAuthentication(
                    'scatterer',
                    director.sentry,
                    routine = 'addscatterer',
                    label = 'add',
                    ),  director.cgihome
                )
            continue

        p = document.paragraph()
        link = action_link(
            actionRequireAuthentication(
                'sampleassemblywizard',
                director.sentry,
                routine = 'addscatterer',
                label = 'add',
                ),  director.cgihome
            )
        p.text = [
예제 #34
0
        # start document
        main = page._body._content._main
        document = self._document( main, director )
        self._tree( document, director )
        
        # create form
        form = document.form(
            name='instrument',
            legend= formcomponent.legend(),
            action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(
            actor = 'instrument', sentry = director.sentry,
            label = '', routine = 'set',
            arguments = { 'id': self.inventory.id,
                          'form-received': formcomponent.name } )
        from vnf.weaver import action_formfields
        action_formfields( action, form )

        # expand the form with fields of the data object that is being edited
        formcomponent.expand( form )

        # ok button
        submit = form.control(name="submit", type="submit", value="OK")
        
        return page


    def set(self, director):
예제 #35
0
class NeutronExperimentWizard(base):
    class Inventory(base.Inventory):

        import pyre.inventory

        id = pyre.inventory.str("id", default='')
        id.meta['tip'] = "the unique identifier of the experiment"

        ncount = pyre.inventory.str('ncount', default=1e6)
        ncount.meta['tip'] = 'number of neutrons'

        pass  # end of Inventory

    def start(self, director):
        try:
            page = director.retrieveSecurePage('neutronexperimentwizard')
        except AuthenticationError, err:
            return err.page

        if self.inventory.id == '':
            #create a new experiment
            from vnf.dom.NeutronExperiment import NeutronExperiment
            experiment = director.clerk.new_ownedobject(NeutronExperiment)
            experiment.status = 'started'
            director.clerk.updateRecord(experiment)
            #need to reload the page so that id is correctly
            self.inventory.id = experiment.id
            page = director.retrieveSecurePage('neutronexperimentwizard')
            pass

        main = page._body._content._main

        # populate the main column
        document = main.document(title='Neutron Experiment Wizard: start')
        document.description = ''
        document.byline = 'byline?'

        p = document.paragraph()
        p.text = [
            'To run a virtual neutron experiment, you will need to select',
            'a neutron instrument, prepare your sample, put your',
            'sample in a sample holder, select instrument parameters',
            'for this experiment, and finally pick a computation server',
            'to run your virtual neutron experiment.',
            'Default values are provided for all these characteristics',
            'of the experiment, but please review them before launching',
            'your simulation.',
        ]

        p = document.paragraph()
        p.text = [
            'Please first assign a name to this experiment:',
        ]

        formcomponent = self.retrieveFormToShow(
            'neutronexperimentwizard_start')
        formcomponent.inventory.experiment_id = self.inventory.id
        formcomponent.director = director

        # create form
        form = document.form(name='start',
                             legend=formcomponent.legend(),
                             action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(
            actor='neutronexperimentwizard',
            sentry=director.sentry,
            label='',
            routine='verify_experiment_name',
            id=self.inventory.id,
            arguments={'form-received': formcomponent.name})
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)

        # run button
        submit = form.control(name="actor.form-received.submit",
                              type="submit",
                              value="Continue")

        #        self._footer( document, director )
        return page
예제 #36
0
        #
        # create form
        formcomponent = self.retrieveFormToShow('selectshapetype')
        formcomponent.inventory.id = shape.id
        formcomponent.director = director

        form = document.form(name='selectshapetype',
                             legend=formcomponent.legend(),
                             action=director.cgihome)

        # specify action
        action = actionRequireAuthentication(actor='scatterer',
                                             sentry=director.sentry,
                                             label='',
                                             routine='editshape',
                                             arguments={
                                                 'id':
                                                 self.inventory.id,
                                                 'form-received':
                                                 formcomponent.name
                                             })
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)

        # ok button
        submit = form.control(name="submit", type="submit", value="OK")

        return page
예제 #37
0
#        experiment = director.clerk.getNeutronExperiment(self.inventory.id)
        main = page._body._content._main
        # populate the main column
        document = main.document(title='Sample input')
        document.description = ''
        document.byline = '<a href="http://danse.us">DANSE</a>'

        formcomponent = self.retrieveFormToShow('selectShape')
        formcomponent.director = director
        # build the form
        form = document.form(name='', action=director.cgihome)
        # specify action
        action = actionRequireAuthentication(
            actor='sampleInput',
            sentry=director.sentry,
            routine='onShapeSelect',
            label='',
            id=self.inventory.id,
            arguments={'form-received': formcomponent.name},
        )
        from vnf.weaver import action_formfields
        action_formfields(action, form)

        # expand the form with fields of the data object that is being edited
        formcomponent.expand(form)
        submit = form.control(name='submit', type="submit", value="next")
        #self.processFormInputs(director)
        return page

    def onShapeSelect(self, director):
        selected = self.processFormInputs(director)
        method = getattr(self, selected)
예제 #38
0
#        experiment = director.clerk.getNeutronExperiment(self.inventory.id)
        main = page._body._content._main
        # populate the main column
        document = main.document(title='Sample input')
        document.description = ''
        document.byline = '<a href="http://danse.us">DANSE</a>'        
        
        formcomponent = self.retrieveFormToShow( 'selectShape')
        formcomponent.director = director
        # build the form 
        form = document.form(name='', action=director.cgihome)
        # specify action
        action = actionRequireAuthentication(          
            actor = 'sampleInput', 
            sentry = director.sentry,
            routine = 'onShapeSelect',
            label = '',
            id=self.inventory.id,
            arguments = {'form-received': formcomponent.name },
            )
        from vnf.weaver import action_formfields
        action_formfields( action, form )
        
        # expand the form with fields of the data object that is being edited
        formcomponent.expand( form )
        submit = form.control(name='submit',type="submit", value="next")
        #self.processFormInputs(director)
        return page  
    
    def onShapeSelect(self, director):
        selected = self.processFormInputs(director)
        method = getattr(self, selected )