Example #1
0
 def getView(self):
     tr=ecs.Tr()
     for val, label in self.options:
         b=ecs.Button(label, attributes={'name' : self.name,
                                         'value': htmlquote(str(val))})
         tr.addElement(ecs.Td(b))
     return ecs.Table(tr)
def _genUrl ( path, query = {}, need_full = 0, noescape=None ):
    """
    Generate the URL given a URI. If need_full is 1, the generated URL 
    will contain the server part.
    """

    if noescape is None:
	path = urllib.quote(path)

    if query:
        path = path + htmlquote(skunklib.urlencode(query))

    if need_full:
        if path[0] != '/':
            raise SkunkRuntimeError, \
                'full url being generated with relative path: %s' % path
        conn=AE.Component.componentStack[0].namespace['CONNECTION']
        if conn.env.get('HTTPS')=='on':
            scheme='https'
        else:
            scheme='http'
        host=conn.requestHeaders.get('Host')
        if not host:
            host=conn.env.get('SERVER_NAME')
            port=conn.env.get("SERVER_PORT")
            if port:
                if (scheme=='http' and not port=='80') or (scheme=='https' and not port=='443'):
                    host='%s:%s' % (host, port)
        url='%s://%s%s' % (scheme, host, path)

    else:
        url = path

    return url
Example #3
0
 def getView(self):
     elem=ecs.Textarea()
     if self.name is not None:
         elem.setAttribute('name', self.name)
     if self.value is not None:
         elem.addElement(htmlquote(str(self.value)))
     elem.attributes.update(self.view_attrs)
     return elem
Example #4
0
 def getView(self):
     elem=ecs.Input({'type' : self.type})
     if self.name is not None:
         elem.setAttribute('name', self.name)
     if self.value is not None:
         elem.setAttribute('value', htmlquote(str(self.value)))
     elem.attributes.update(self.view_attrs)
     return elem
Example #5
0
 def getView(self):
     elem=ecs.Input({'type' : self.inputType})
     if self.name is not None:
         elem.setAttribute('name', self.name)
     if self.value is not None:
         elem.setAttribute('value', htmlquote(str(self.value)))
     if self.inputType in ('radio', 'checkbox') and self.checked:
         elem.setAttribute('checked', 'checked')
     elem.attributes.update(self.view_attrs)
     return elem
Example #6
0
 def getView(self):
     elem=ecs.Option()
     elem.addElement(self.description)
     if self.selected:
         elem.setAttribute('selected', 'selected')
     if self.label is not None:
         elem.setAttribute('label', self.label)
     elem.setAttribute('value', htmlquote(str(self.name)))
     elem.attributes.update(self.view_attrs)
     return elem
Example #7
0
 def getView(self):
     elem=ecs.Button()
     if self.name!=None:
         elem.setAttribute('name', self.name)
     if self.value is not None:
         elem.setAttribute('value', htmlquote(str(self.value)))
     if isinstance(self.content, list) or isinstance(self.content, tuple):
         for c in self.content:
             elem.addElement(c)
     else:
         elem.addElement(self.content)
     elem.attributes.update(self.view_attrs)
     return elem
def _genUrl(path, query={}, need_full=0, noescape=None):
    """
    Generate the URL given a URI. If need_full is 1, the generated URL 
    will contain the server part.
    """

    if noescape is None:
        path = urllib.quote(path)

    if query:
        path = path + htmlquote(skunklib.urlencode(query))

    if need_full:
        if path[0] != '/':
            raise SkunkRuntimeError, \
                'full url being generated with relative path: %s' % path
        conn = AE.Component.componentStack[0].namespace['CONNECTION']
        if conn.env.get('HTTPS') == 'on':
            scheme = 'https'
        else:
            scheme = 'http'
        host = conn.requestHeaders.get('Host')
        if not host:
            host = conn.env.get('SERVER_NAME')
            port = conn.env.get("SERVER_PORT")
            if port:
                if (scheme == 'http'
                        and not port == '80') or (scheme == 'https'
                                                  and not port == '443'):
                    host = '%s:%s' % (host, port)
        url = '%s://%s%s' % (scheme, host, path)

    else:
        url = path

    return url