Changeset 3059:b04f5f6f9a3f in livinglogic.python.xist

Show
Ignore:
Timestamp:
12/19/07 15:43:12 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Use Publisher.getprefix() to get the prefix for the taglib thingie. Add missing attributes to option.

Location:
src/ll/xist
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/ns/struts_html.py

    r2903 r3059  
    2929    def publish(self, publisher): 
    3030        yield publisher.encode(u'<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="') 
    31         try: 
    32             prefix = publisher._ns2prefix[xmlns] 
    33         except KeyError: 
    34             raise xsc.PrefixNeededError(xmlns) 
    35         else: 
    36             if prefix is None: 
    37                 raise xsc.PrefixNeededError(xmlns) 
    38             yield publisher.encode(prefix) 
     31        yield publisher.encode(publisher.getprefix(self)) 
    3932        yield publisher.encode(u'" %>') 
    4033 
     
    397390    class Attrs(Element.Attrs): 
    398391        class value(xsc.TextAttr): pass 
     392        class bundle(xsc.TextAttr): pass 
     393        class locale(xsc.TextAttr): pass 
     394        class key(xsc.TextAttr): pass 
     395        class disabled(xsc.TextAttr): pass 
    399396 
    400397 
  • src/ll/xist/publishers.py

    r2946 r3059  
    173173    def getprefix(self, object): 
    174174        """ 
    175         FIXME: Can be used during publication by custom publish methods: Return the prefix 
    176         configured for the namespace <arg>xmlns</arg>. 
     175        Can be used during publication by custom publish methods: Return the prefix 
     176        configured for object <arg>object</arg>. 
    177177        """ 
    178178        xmlns = getattr(object, "xmlns") 
    179179        if xmlns is not None: 
    180             emptyok = isinstance(object, xsc.Element) 
     180            emptyok = isinstance(object, xsc.Element) # If it's e.g. a procinst assume we need a non-empty prefix 
    181181            try: 
    182182                prefix = self._ns2prefix[xmlns] 
     
    220220 
    221221        # Do we have to publish xmlns attributes? 
     222        self._publishxmlns = False 
    222223        if self._ns2prefix: 
    223224            # Determine if we have multiple roots 
    224             if isinstance(node, xsc.Frag) and misc.count(node[xsc.Element]) > 1: 
    225                 raise xsc.MultipleRootsError() 
     225            if isinstance(node, xsc.Frag): 
     226                count = 0 
     227                for child in node: 
     228                    if isinstance(node, xsc.Element) and node.xmlns not in self.hidexmlns: 
     229                        count += 1 
     230                if count > 1: 
     231                    raise xsc.MultipleRootsError() 
    226232            self._publishxmlns = True 
    227         else: 
    228             self._publishxmlns = False 
    229233 
    230234        self.inattr = 0