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
def insert(ctx = annotate.Context(), title = annotate.String(), author = annotate.String(), image = annotate.FileUpload(required=True, requiredFailMessage="Must upload something") ): """ Insert a new image """
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
def bind_delete(self, ctx): return annotate.MethodBinding( 'delete', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), ], label=_('Confirm delete')), action=_('Delete'))
def bind_cancel(self, ctx): return annotate.MethodBinding( 'cancel', annotate.Method(arguments=[ annotate.Argument('context', annotate.Context()), ], label=_('Cancel')), action=_('Cancel'))
def bind_generateRandom(self, ctx): return annotate.MethodBinding( 'generateRandom', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), ], label=_('Generate random')), action=_('Generate random'))
def bind_remove(self, ctx): return annotate.MethodBinding('remove', annotate.Method(arguments=[ annotate.Argument( 'ctx', annotate.Context()), ], label=_('Remove')), action=_('Remove'))
def _getFormFields(self): r = [] r.append(annotate.Argument('context', annotate.Context())) process = {} # TODO sort objectclasses somehow? objectClasses = list(self.chosenObjectClasses) objectClassesSeen = {} self.nonUserEditableAttributes = [] while objectClasses: objectClass = objectClasses.pop() objclassName = objectClass.name[0] if objectClassesSeen.has_key(objclassName): continue objectClassesSeen[objclassName] = 1 for ocName in objectClass.sup or []: objclass = mapNameToObjectClass(self.objectClasses, ocName) assert objclass, "Objectclass %s must have schema" % objclassName objectClasses.append(objclass) for attr_alias in objectClass.must: real_attr = self._get_attrtype(str(attr_alias)) if hasattr(self, 'nonUserEditableAttributeType_' + real_attr.name[0]): self.nonUserEditableAttributes.append(real_attr.name[0]) else: for attr in real_attr.name: if not process.has_key(attr.upper()): process[attr.upper()] = 0 if not process[attr.upper()]: self._one_formfield(attr, result=r, must=True) for name in real_attr.name: process[name.upper()] = 1 for attr_alias in objectClass.may: real_attr = self._get_attrtype(str(attr_alias)) if hasattr(self, 'nonUserEditableAttributeType_' + real_attr.name[0]): self.nonUserEditableAttributes.append(real_attr.name[0]) else: for attr in real_attr.name: if not process.has_key(attr.upper()): process[attr.upper()] = 0 if not process[attr.upper()]: self._one_formfield(attr, result=r) for name in real_attr.name: process[name.upper()] = 1 assert [v == 1 for k, v in process.items()], "TODO: %s" % process return r
def bind_add(self, ctx): return annotate.MethodBinding( 'add', annotate.Method(arguments=[ annotate.Argument('context', annotate.Context()), annotate.Argument('smartObjectClass', annotate.Choice(choices=self.plugins)), ], label=_('Add')), action=_('Add'))
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
def bind_go(self, ctx): return annotate.MethodBinding( 'go', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), annotate.Argument( 'baseDN', LDAPDN(label=_('Base DN'), description=_( "The top-level LDAP DN you want" " to browse, e.g. dc=example,dc=com"))), ], label=_('Go')), action=_('Go'))
def bind_setServicePassword(self, ctx): return annotate.MethodBinding( 'setServicePassword', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), annotate.Argument( 'newPassword', annotate.PasswordEntry(required=True, label=_('New password'))), annotate.Argument( 'again', annotate.PasswordEntry(required=True, label=_('Again'))), ], label=_('Set password')), action=_('Set password'))
def __init__(self, objectClasses): super(AddOCForm, self).__init__(None) structural = [] auxiliary = [] for oc in objectClasses: if oc.type == 'STRUCTURAL': structural.append(oc) elif oc.type == 'AUXILIARY': auxiliary.append(oc) structural.sort() auxiliary.sort() class KludgeNevowChoice(object): """ A kludge that allows using Choice with both Nevow 0.3 and newer. """ def __init__(self, oc): self.name = oc.name self.desc = oc.desc def __str__(self): """ For Choice in Nevow 0.4 and newer. Nevow 0.3 will use integer indexes. Actual stringification for display purposes happens in strObjectClass. """ return self.name[0] formFields = [ annotate.Argument('ctx', annotate.Context()), annotate.Argument('request', annotate.Request()), annotate.Argument( 'structuralObjectClass', annotate.Choice( label=_('Object type to create'), choices=[KludgeNevowChoice(x) for x in structural], stringify=strObjectClass)), ] for oc in auxiliary: formFields.append( annotate.Argument( 'auxiliary_%s' % oc.name[0], annotate.Boolean(label=oc.name[0], description=oc.desc or ''))) self.formFields = formFields
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'))
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')))
def insert(ctx=annotate.Context(), description=annotate.String( required=True, requiredFailMessage="Description Missing")): pass
def update(ctx=annotate.Context(), id=annotate.Integer(), oldstate=annotate.Integer()): pass
def delete(ctx=annotate.Context(), id=annotate.Integer()): pass
def updateWiki(self, ctx=annotate.Context(), text=annotate.Text(), new=annotate.String(hidden=True)): pass
def stopServer(self, ctx=annotate.Context()): pass
def kickUser(self, ctx=annotate.Context(), username=annotate.String(required=True)): pass
def deleteGame(self, ctx=annotate.Context(), gameId=annotate.String(required=True)): pass
def modifyUser(self, ctx=annotate.Context(), oldPassword=annotate.PasswordEntry(), password=annotate.Password(), isAdministrator=isAdmin): pass
def addNewBulletin(self, ctx=annotate.Context(), message=annotate.String(required=True)): pass
def resetRank(self, ctx=annotate.Context()): pass
def sendLogMessage(ctx=annotate.Context(), level=annotate.Choice(LogLevels, required=True, label=_("Log message level")), message=annotate.String(label=_("Message text"))): pass
def deleteBulletin(self, ctx=annotate.Context(), bulletinId=annotate.String(required=True)): pass