Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Properties | Private Member Functions | Static Private Attributes
MoinMoin.web.contexts.BaseContext Class Reference
Inheritance diagram for MoinMoin.web.contexts.BaseContext:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.web.contexts.BaseContext:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def cfg
def getText
def isSpiderAgent
def rootpage
def rev
def setContentLanguage
def initTheme
def become
def __repr__

Public Attributes

 content_lang
 current_lang
 request
 environ
 personalities

Static Public Attributes

tuple action = EnvironProxy('action', lambda o: o.request.values.get('action', 'show'))
tuple clock = EnvironProxy('clock', lambda o: Clock())
tuple user = EnvironProxy('user', lambda o: user.User(o, auth_method='request:invalid'))
tuple lang = EnvironProxy('lang')
tuple content_lang = EnvironProxy('content_lang', lambda o: o.cfg.language_default)
tuple current_lang = EnvironProxy('current_lang')
tuple html_formatter = EnvironProxy('html_formatter', lambda o: text_html.Formatter(o))
tuple formatter = EnvironProxy('formatter', lambda o: o.html_formatter)
tuple page = EnvironProxy('page', None)
tuple cfg = EnvironProxy(cfg)
tuple isSpiderAgent = EnvironProxy(isSpiderAgent)
tuple rootpage = EnvironProxy(rootpage)
tuple rev = EnvironProxy(rev)
tuple theme = EnvironProxy('theme', _theme)

Properties

 getText = property(getText)

Private Member Functions

def _theme

Static Private Attributes

 _ = getText

Detailed Description

Implements a basic context, that provides some common attributes.
Most attributes are lazily initialized via descriptors. 

Definition at line 104 of file contexts.py.


Member Function Documentation

def MoinMoin.web.contexts.Context.__repr__ (   self) [inherited]

Definition at line 101 of file contexts.py.

00101 
00102     def __repr__(self):
00103         return "<%s %r>" % (self.__class__.__name__, self.personalities)

def MoinMoin.web.contexts.BaseContext._theme (   self) [private]

Definition at line 165 of file contexts.py.

00165 
00166     def _theme(self):
00167         self.initTheme()
        return self.theme

Here is the call graph for this function:

def MoinMoin.web.contexts.Context.become (   self,
  cls 
) [inherited]
Become another context, based on given class.

@param cls: class to change to, must be a sister class
@rtype: boolean
@return: wether a class change took place

Definition at line 87 of file contexts.py.

00087 
00088     def become(self, cls):
00089         """ Become another context, based on given class.
00090 
00091         @param cls: class to change to, must be a sister class
00092         @rtype: boolean
00093         @return: wether a class change took place
00094         """
00095         if self.__class__ is cls:
00096             return False
00097         else:
00098             self.personalities.append(cls)
00099             self.__class__ = cls
00100             return True

Definition at line 123 of file contexts.py.

00123 
00124     def cfg(self):
00125         if self.request.given_config is not None:
00126             return self.request.given_config('MoinMoin._tests.wikiconfig')
00127         try:
00128             self.clock.start('load_multi_cfg')
00129             cfg = multiconfig.getConfig(self.request.url)
00130             self.clock.stop('load_multi_cfg')
00131             return cfg
00132         except error.NoConfigMatchedError:
            raise NotFound('<p>No wiki configuration matching the URL found!</p>')

Definition at line 135 of file contexts.py.

00135 
00136     def getText(self):
00137         lang = self.lang
00138         def _(text, i18n=i18n, request=self, lang=lang, **kw):
00139             return i18n.getText(text, request, lang, **kw)
00140         return _

Set theme - forced theme, user theme or wiki default 

Definition at line 181 of file contexts.py.

00181 
00182     def initTheme(self):
00183         """ Set theme - forced theme, user theme or wiki default """
00184         if self.cfg.theme_force:
00185             theme_name = self.cfg.theme_default
00186         else:
00187             theme_name = self.user.theme_name
00188         load_theme_fallback(self, theme_name)
00189 

Here is the call graph for this function:

Here is the caller graph for this function:

Simple check if useragent is a spider bot. 

Definition at line 144 of file contexts.py.

00144 
00145     def isSpiderAgent(self):
00146         """ Simple check if useragent is a spider bot. """
00147         cfg = self.cfg
00148         user_agent = self.request.user_agent
00149         if user_agent and cfg.cache.ua_spiders:
00150             return cfg.cache.ua_spiders.search(user_agent.browser) is not None
        return False

Definition at line 158 of file contexts.py.

00158 
00159     def rev(self):
00160         try:
00161             return int(self.values['rev'])
00162         except:
            return None

Here is the call graph for this function:

Definition at line 153 of file contexts.py.

00153 
00154     def rootpage(self):
00155         from MoinMoin.Page import RootPage
        return RootPage(self)
Set the content language, used for the content div

Actions that generate content in the user language, like search,
should set the content direction to the user language before they
call send_title!

Definition at line 171 of file contexts.py.

00171 
00172     def setContentLanguage(self, lang):
00173         """ Set the content language, used for the content div
00174 
00175         Actions that generate content in the user language, like search,
00176         should set the content direction to the user language before they
00177         call send_title!
00178         """
00179         self.content_lang = lang
00180         self.current_lang = lang


Member Data Documentation

Definition at line 142 of file contexts.py.

tuple MoinMoin.web.contexts.BaseContext.action = EnvironProxy('action', lambda o: o.request.values.get('action', 'show')) [static]

Definition at line 109 of file contexts.py.

Definition at line 133 of file contexts.py.

Definition at line 110 of file contexts.py.

tuple MoinMoin.web.contexts.BaseContext.content_lang = EnvironProxy('content_lang', lambda o: o.cfg.language_default) [static]

Definition at line 114 of file contexts.py.

Definition at line 178 of file contexts.py.

Definition at line 115 of file contexts.py.

Definition at line 179 of file contexts.py.

Definition at line 81 of file contexts.py.

tuple MoinMoin.web.contexts.BaseContext.formatter = EnvironProxy('formatter', lambda o: o.html_formatter) [static]

Definition at line 118 of file contexts.py.

tuple MoinMoin.web.contexts.BaseContext.html_formatter = EnvironProxy('html_formatter', lambda o: text_html.Formatter(o)) [static]

Definition at line 117 of file contexts.py.

Definition at line 151 of file contexts.py.

Definition at line 113 of file contexts.py.

Definition at line 120 of file contexts.py.

Definition at line 82 of file contexts.py.

Definition at line 80 of file contexts.py.

Definition at line 163 of file contexts.py.

Definition at line 156 of file contexts.py.

Definition at line 168 of file contexts.py.

tuple MoinMoin.web.contexts.BaseContext.user = EnvironProxy('user', lambda o: user.User(o, auth_method='request:invalid')) [static]

Definition at line 111 of file contexts.py.


Property Documentation

Definition at line 141 of file contexts.py.


The documentation for this class was generated from the following file: