<s> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> from django . conf import settings <EOL> from lino . api import dd , rt <EOL> from lino . utils import AttrDict <EOL> from lino . utils . restify import restify <EOL> from lino . utils . restify import doc2rst <EOL> def babelfield ( name , language ) : <EOL> if language == settings . SITE . DEFAULT_LANGUAGE . django_code : <EOL> return name <EOL> return name + '<STR_LIT:_>' + language <EOL> def page ( ref , language , title , body , parent = None , raw_html = False ) : <EOL> if not settings . SITE . get_language_info ( language ) : <EOL> return <EOL> pages = dd . resolve_app ( '<STR_LIT>' , strict = True ) <EOL> obj = pages . lookup ( ref , None ) <EOL> if parent is not None : <EOL> parent = pages . lookup ( parent ) <EOL> if obj is None : <EOL> obj = pages . create_page ( ref = ref ) <EOL> setattr ( obj , '<STR_LIT>' , raw_html ) <EOL> setattr ( obj , '<STR_LIT>' , parent ) <EOL> setattr ( obj , babelfield ( '<STR_LIT:title>' , language ) , title ) <EOL> setattr ( obj , babelfield ( '<STR_LIT:body>' , language ) , body . strip ( ) ) <EOL> obj . full_clean ( ) <EOL> obj . save ( ) <EOL> def objects ( ) : <EOL> yield settings . SITE . site_config <EOL> if False : <EOL> global PAGES <EOL> rv = [ ] <EOL> for obj in list ( PAGES . values ( ) ) : <EOL> yield obj <EOL> PAGES = { } </s>
