示例#1
0
        class FormPage(rend.Page):
            bind_test1 = defer.succeed([('foo', annotate.String()),
                                        ('bar', annotate.Integer())])
            bind_test2 = defer.succeed(
                annotate.MethodBinding(
                    'test2',
                    annotate.Method(arguments=[
                        annotate.Argument('foo', annotate.String())
                    ])))

            bind_test3 = defer.succeed(
                annotate.Property('test3', annotate.Integer()))

            def bind_test4(self, ctx):
                return defer.succeed([('foo', annotate.String()),
                                      ('bar', annotate.Integer())])

            def bind_test5(self, ctx):
                return defer.succeed(
                    annotate.MethodBinding(
                        'test5',
                        annotate.Method(arguments=[
                            annotate.Argument('foo', annotate.String()),
                            annotate.Argument('bar', annotate.Integer())
                        ])))

            docFactory = loaders.stan(html[freeform.renderForms()])
示例#2
0
文件: submit.py 项目: gitGNU/gnu_qsos
 def bind_submitYourContribution(self, ctx):
     "Bind the proper action to perform when submit action is invoked"
     return [('Author', annotate.String()), ('E-mail', annotate.String()),
             ('Description', annotate.Text()),
             ('Type', annotate.Choice(['Evaluation', 'Template',
                                       'Family'])),
             ('File', annotate.FileUpload(required=False))]
示例#3
0
 def search(
         sn=annotate.String(label="Last name"),
         givenName=annotate.String(label="First name"),
         telephoneNumber=annotate.String(),
         description=annotate.String(),
 ):
     pass
示例#4
0
 def insert(ctx = annotate.Context(),
            title = annotate.String(),
            author = annotate.String(),
            image = annotate.FileUpload(required=True,
                                        requiredFailMessage="Must upload something")
            ):
     """ Insert a new image """
示例#5
0
 def doSomething(
         ctx=annotate.Context(),
         fee=annotate.String(required=True, description="Wee!"),
         fi=annotate.Integer(description="Tra-la-la"),
         fo=annotate.Text(),
         fum=annotate.String(),
 ):
     """Do Something Really Exciting
示例#6
0
 def insert(
     ctx = annotate.Context(),
     title = annotate.String(strip=True, required=True, \
                             requiredFailMessage="Title must be provided", tabindex='1'),
     author = annotate.String(strip=True, default="Anonymous", tabindex='2'),
     id = annotate.String(hidden=True),
     category = annotate.Choice(categories, tabindex='3'),
     content = annotate.Text(required=True, \
                             requiredFailMessage="Posts with no content are not allowed", tabindex='4'),
     ):
     pass
示例#7
0
 def login(ctx=annotate.Context(),
           userName=annotate.String(
               required=True, requiredFailMessage='Please enter your name'),
           password=annotate.PasswordEntry(
               required=True,
               requiredFailMessage='Please enter your name')):
     pass
示例#8
0
    def _one_formfield(self, attr, result, must=False):
        attrtype = self._get_attrtype(attr)
        name = attr
        if must:
            name = name + "*"
        if attrtype.uiHint_multiline:
            if attrtype.single_value:
                typed = annotate.Text(label=name,
                                      description=attrtype.desc or '',
                                      required=must)
            else:
                typed = annotate.Text(label=name,
                                      description=attrtype.desc or '',
                                      required=must)
        else:
            if attrtype.single_value:
                typed = annotate.String(label=name,
                                        description=attrtype.desc or '',
                                        required=must)
            else:
                # TODO maybe use a string field+button to add entries,
                # multiselection list+button to remove entries?
                typed = annotate.Text(label=name,
                                      description=attrtype.desc or '',
                                      required=must)

        result.append(annotate.Argument('add_' + attr, typed))
示例#9
0
 def bind_test5(self, ctx):
     return annotate.MethodBinding(
         'test5',
         annotate.Method(arguments=[
             annotate.Argument('foo', annotate.String()),
             annotate.Argument('bar', annotate.Integer())
         ]))
示例#10
0
 def bind_animals(self, ctx, ):
     """Add Animal"""
     return annotate.MethodBinding(
             'animals',
             annotate.Method(arguments=
                 [annotate.Argument('animal', annotate.String()),
                  annotate.Argument('description', annotate.Text())]),
             action="Add Animal",
                                   )
示例#11
0
文件: search.py 项目: Jbran77/ldaptor
    def bind_search(self, ctx):
        l = []
        l.append(annotate.Argument('ctx', annotate.Context()))
        for field in config.getSearchFieldNames():
            l.append(annotate.Argument('search_%s' % field,
                                       annotate.String(label=field)))
        l.append(annotate.Argument('searchfilter',
                                   annotate.String(label=_("Advanced search"))))
        l.append(annotate.Argument(
            'scope',
            annotate.Choice(label=_("Search depth"),
                            choices=[ pureldap.LDAP_SCOPE_wholeSubtree,
                                      pureldap.LDAP_SCOPE_singleLevel,
                                      pureldap.LDAP_SCOPE_baseObject,
                                      ],
                            stringify=strScope,
                            default=pureldap.LDAP_SCOPE_wholeSubtree)))

        return annotate.MethodBinding(
            name='search',
            action=_("Search"),
            typeValue=annotate.Method(arguments=l,
                                      label=_('Search')))
示例#12
0
class ISettings(annotate.TypedInterface):
    platform = annotate.String(label=_("Platform"),
                               default=platform_module.system() + " " +
                               platform_module.release(),
                               immutable=True)

    # TODO version ?

    # pylint: disable=no-self-argument
    def sendLogMessage(ctx=annotate.Context(),
                       level=annotate.Choice(LogLevels,
                                             required=True,
                                             label=_("Log message level")),
                       message=annotate.String(label=_("Message text"))):
        pass

    sendLogMessage = annotate.autocallable(
        sendLogMessage, label=_("Send a message to the log"), action=_("Send"))
示例#13
0
 def bind_add(self, ctx):
     return annotate.MethodBinding(
         'add',
         annotate.Method(arguments=[
             annotate.Argument('ctx', annotate.Context()),
             annotate.Argument(
                 'serviceName',
                 annotate.String(required=True, label=_('Service name'))),
             annotate.Argument(
                 'newPassword',
                 annotate.PasswordEntry(
                     required=False,
                     label=_('New password'),
                     description=_(
                         "Leave empty to generate random password."))),
             annotate.Argument(
                 'again',
                 annotate.PasswordEntry(required=False, label=_('Again'))),
         ],
                         label=_('Add')),
         action=_('Add'))
示例#14
0
 def bind_name(self, ctx):
     return [('name', annotate.String())]
示例#15
0
 def addElement(name=annotate.String(required=True), type=typeChoice):
     """Add Element
     
     Add an element to this form.
     """
     pass
示例#16
0
文件: wiki.py 项目: nanonyme/pgasync
 def updateWiki(self,
                ctx=annotate.Context(),
                text=annotate.Text(),
                new=annotate.String(hidden=True)):
     pass
示例#17
0
# Configure the web interface to include the BACnet config parameters
    WebSettings.addSettings(
        "BACnetConfigParm",                # name
        _("BACnet Configuration"),         # description
        webFormInterface,                  # fields
        _("Apply"),  # button label
        OnButtonSave)                      # callback    

# Add the Delete button to the web interface
    WebSettings.addSettings(
        "BACnetConfigDelSaved",                   # name
        _("BACnet Configuration"),                # description
        [ ("status",
           annotate.String(label=_("Current state"),
                           immutable=True,
                           default=lambda *k:getConfigStatus())),
        ],                                       # fields  (empty, no parameters required!)
        _("Reset"), # button label
        OnButtonReset) 


def getConfigStatus():
    if _WebviewConfiguration == _DefaultConfiguration:
        return "Unchanged"
    return "Modified"


# location_str is replaced by extension's value in CTNGenerateC call
def _runtime_bacnet_websettings_%(location_str)s_cleanup():
示例#18
0
文件: prefs.py 项目: xregist/shtoom
    def fwd(self, req=annotate.Request(), name=annotate.String(label="Configuration Name"), username=annotate.String(), password=annotate.PasswordEntry()):
        """Free World Dialup Account

        Add a configuration for a FWD account.
        """
        pass
示例#19
0
文件: prefs.py 项目: xregist/shtoom
    def divmod(self, req=annotate.Request(), name=annotate.String(label="Configuration Name"), username=annotate.String(), password=annotate.PasswordEntry()):
        """Divmod Account

        Add a configuration for a Divmod account.
        """
        pass
示例#20
0
registerAdapter(FileUploadDownloadRenderer, FileUploadDownload,
                formless.iformless.ITypedRenderer)


def getDownloadUrl(ctx, argument):
    if lastKnownConfig is not None:
        return url.URL.fromContext(ctx).\
            child(WAMP_SECRET_URL).\
            child(lastKnownConfig["ID"] + ".secret")


webFormInterface = [
    ("status",
     annotate.String(label=_("Current status"),
                     immutable=True,
                     default=lambda *k: getWampStatus())),
    ("ID", annotate.String(label=_("ID"), default=wampConfigDefault)),
    ("secretfile",
     FileUploadDownload(label=_("File containing secret for that ID"),
                        download_url=getDownloadUrl)),
    ("active",
     annotate.Boolean(label=_("Enable WAMP connection"),
                      default=wampConfigDefault)),
    ("url",
     annotate.String(label=_("WAMP Server URL"), default=wampConfigDefault))
]


def deliverWampSecret(ctx, segments):
    # filename = segments[1].decode('utf-8')
示例#21
0
 def bind_test4(self, ctx):
     return defer.succeed([('foo', annotate.String()),
                           ('bar', annotate.Integer())])
示例#22
0
def _AddWebNode(C_node_id, node_type, GetParamFuncs, SetParamFuncs):
    """
    Load from the compiled code (.so file, aloready loaded into memmory)
    the configuration parameters of a specific Modbus plugin node.
    This function works with both client and server nodes, depending on the
    Get/SetParamFunc dictionaries passed to it (either the client or the server
    node versions of the Get/Set functions)
    """
    WebNode_entry = {}

    # Get the config_name from the C code...
    config_name = GetParamFuncs["config_name"](C_node_id)
    # Get the addr_type from the C code...
    # addr_type will be one of "tcp", "rtu" or "ascii"
    addr_type   = GetParamFuncs["addr_type"  ](C_node_id)   
    # For some operations we cannot use the config name (e.g. filename to store config)
    # because the user may be using characters that are invalid for that purpose ('/' for
    # example), so we create a hash of the config_name, and use that instead.
    config_hash = hashlib.md5(config_name).hexdigest()
    
    #PLCObject.LogMessage("Modbus web server extension::_AddWebNode("+str(C_node_id)+") config_name="+config_name)

    # Add the new entry to the global list
    # Note: it is OK, and actually necessary, to do this _before_ seting all the parameters in WebNode_entry
    #       WebNode_entry will be stored as a reference, so we can later insert parameters at will.
    global _WebNodeList
    _WebNodeList.append(WebNode_entry)
    WebNode_id = len(_WebNodeList) - 1

    # store all WebNode relevant data for future reference
    #
    # Note that "WebParamList" will reference one of:
    #  - TCPclient_parameters, TCPserver_parameters, RTUclient_parameters, RTUslave_parameters
    WebNode_entry["C_node_id"    ] = C_node_id
    WebNode_entry["config_name"  ] = config_name 
    WebNode_entry["config_hash"  ] = config_hash
    WebNode_entry["filename"     ] = os.path.join(_ModbusConfFiledir, "Modbus_config_" + config_hash + ".json")
    WebNode_entry["GetParamFuncs"] = GetParamFuncs
    WebNode_entry["SetParamFuncs"] = SetParamFuncs
    WebNode_entry["WebParamList" ] = WebParamListDictDict[node_type][addr_type] 
    WebNode_entry["addr_type"    ] = addr_type  # 'tcp', 'rtu', or 'ascii' (as returned by C function)
    WebNode_entry["node_type"    ] = node_type  # 'client', 'server'
        
    
    # Dictionary that contains the Modbus configuration currently being shown
    # on the web interface
    # This configuration will almost always be identical to the current
    # configuration in the PLC (i.e., the current state stored in the 
    # C variables in the .so file).
    # The configuration viewed on the web will only be different to the current 
    # configuration when the user edits the configuration, and when
    # the user asks to save an edited configuration that contains an error.
    WebNode_entry["WebviewConfiguration"] = None

    # Upon PLC load, this Dictionary is initialised with the Modbus configuration
    # hardcoded in the C file
    # (i.e. the configuration inserted in Beremiz IDE when project was compiled)
    WebNode_entry["DefaultConfiguration"] = _GetPLCConfiguration(WebNode_id)
    WebNode_entry["WebviewConfiguration"] = WebNode_entry["DefaultConfiguration"]
    
    # Dictionary that stores the Modbus configuration currently stored in a file
    # Currently only used to decide whether or not to show the "Delete" button on the
    # web interface (only shown if "SavedConfiguration" is not None)
    SavedConfig = _GetSavedConfiguration(WebNode_id)
    WebNode_entry["SavedConfiguration"] = SavedConfig
    
    if SavedConfig is not None:
        _SetPLCConfiguration(WebNode_id, SavedConfig)
        WebNode_entry["WebviewConfiguration"] = SavedConfig
        
    # Define the format for the web form used to show/change the current parameters
    # We first declare a dynamic function to work as callback to obtain the default values for each parameter
    # Note: We transform every parameter into a string
    #       This is not strictly required for parameters of type annotate.Integer that will correctly
    #           accept the default value as an Integer python object
    #       This is obviously also not required for parameters of type annotate.String, that are
    #           always handled as strings.
    #       However, the annotate.Choice parameters (and all parameters that derive from it,
    #           sucn as Parity, Baud, etc.) require the default value as a string
    #           even though we store it as an integer, which is the data type expected
    #           by the set_***() C functions in mb_runtime.c
    def __GetWebviewConfigurationValue(ctx, argument):
        return str(_GetWebviewConfigurationValue(ctx, WebNode_id, argument))
    
    webFormInterface = [(name, web_dtype (label=web_label, default=__GetWebviewConfigurationValue)) 
                    for name, web_label, c_dtype, web_dtype in WebNode_entry["WebParamList"]]

    # Configure the web interface to include the Modbus config parameters
    def __OnButtonSave(**kwargs):
        OnButtonSave(WebNode_id=WebNode_id, **kwargs)

    WebSettings = NS.newExtensionSetting("Modbus #"+ str(WebNode_id), config_hash)

    WebSettings.addSettings(
        "ModbusConfigParm"          + config_hash,     # name (internal, may not contain spaces, ...)
        _("Modbus Configuration: ") + config_name,     # description (user visible label)
        webFormInterface,                              # fields
        _("Apply"), # button label
        __OnButtonSave)                                # callback   
    
    def __OnButtonReset(**kwargs):
        return OnButtonReset(WebNode_id = WebNode_id, **kwargs)
            
    def getConfigStatus():
        if WebNode_entry["WebviewConfiguration"] == WebNode_entry["DefaultConfiguration"]:
            return "Unchanged"
        return "Modified"

    WebSettings.addSettings(
        "ModbusConfigDelSaved"      + config_hash,  # name (internal, may not contain spaces, ...)
        _("Modbus Configuration: ") + config_name,  # description (user visible label)
        [ ("status",
           annotate.String(label=_("Current state"),
                           immutable=True,
                           default=lambda *k:getConfigStatus())),
        ],                                       # fields  (empty, no parameters required!)
        _("Reset"), # button label
        __OnButtonReset)
示例#23
0
 def addPasting(request=annotate.Request(),
                author=annotate.String(strip=True),
                text=annotate.Text(strip=True, required=True)):
     pass
示例#24
0
文件: tree.py 项目: schwabe/nevow
 def deleteChild(name=annotate.String(required=True)):
     pass
示例#25
0
 def insert(ctx=annotate.Context(),
            description=annotate.String(
                required=True, requiredFailMessage="Description Missing")):
     pass
示例#26
0
 def editPasting(request=annotate.Request(),
                 postedBy=annotate.String(immutable=1),
                 author=annotate.String(strip=True),
                 text=annotate.Text(strip=True, required=True)):
     pass
示例#27
0
文件: tree.py 项目: schwabe/nevow
 def setDescription(description=annotate.String()):
     pass
示例#28
0
 def addItem(newSubject=annotate.String()):
     pass
示例#29
0
文件: tree.py 项目: schwabe/nevow
 def addChild(name=annotate.String(required=True),
                    description=annotate.String()):
     pass
示例#30
0
 def setSubject(newSubject=annotate.String(label="Change Subject")):
     pass