Exemplo n.º 1
0
class EditDifferent(grok.EditForm):
    grok.context(DifferentMammoth)
Exemplo n.º 2
0
class BrackerBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Pot)

    def render(self):
        return "Brack Bone"
Exemplo n.º 3
0
class NamedViewletManager(grok.ViewletManager):
    grok.context(Interface)
    grok.name('managerwithname')
Exemplo n.º 4
0
class CaveView(grok.View):
    grok.context(Interface)
Exemplo n.º 5
0
class Pot(grok.ViewletManager):
    grok.context(Interface)
    grok.name('pot')
import grok
from zope import interface

class Cave(grok.Model):
    pass

class Club(grok.Model):
    pass

grok.context(Cave)
grok.context(Club)
Exemplo n.º 7
0
"""
Explicit module-level context for an imported model:

  >>> grok.testing.grok(__name__)

  >>> cave = Cave()
  >>> painting = IPainting(cave)

  >>> IPainting.providedBy(painting)
  True
  >>> isinstance(painting, Painting)
  True

"""
import grok
from grok.tests.adapter.adapter import Cave
from zope import interface

grok.context(Cave)

class IPainting(interface.Interface):
    pass

class Painting(grok.Adapter):
    grok.implements(IPainting)
Exemplo n.º 8
0
from zope.app.apidoc import utilities, codemodule
from zope.app.apidoc.utilities import getPythonPath, renderText, columnize
from zope.app.apidoc.codemodule.module import Module
from zope.app.apidoc.codemodule.class_ import Class
from zope.app.apidoc.codemodule.function import Function
from zope.app.apidoc.codemodule.text import TextFile
from zope.app.apidoc.codemodule.zcml import ZCMLFile
from zope.app.folder.interfaces import IRootFolder
from zope.app.security.interfaces import ILogout, IAuthentication
from zope.app.security.interfaces import IUnauthenticatedPrincipal
from zope.proxy import removeAllProxies
from zope.tal.taldefs import attrEscape

import z3c.flashmessage.interfaces

grok.context(IRootFolder)
grok.define_permission('grok.ManageApplications')


class Add(grok.View):
    """Add an application.
    """

    grok.require('grok.ManageApplications')

    def update(self, inspectapp=None, application=None):
        if inspectapp is not None:
            self.redirect(
                self.url("docgrok") + "/%s/index" %
                (application.replace('.', '/'), ))
        return
Exemplo n.º 9
0
class Macros(GAIAView):
    """Provides the o-wrap layout."""

    grok.context(Interface)
Exemplo n.º 10
0
class EntryIndex(grok.View):
    grok.context(Entry)
    grok.name('index')
Exemplo n.º 11
0
class WorkflowState(hurry.workflow.workflow.WorkflowState, grok.Adapter):
    grok.context(uvcsite.content.interfaces.IContent)
    grok.provides(hurry.workflow.interfaces.IWorkflowState)
Exemplo n.º 12
0
class NoneFormat(grok.View):
    grok.name('format')
    grok.context(None.__class__)

    def render(self):
        return ''
Exemplo n.º 13
0
class Footer(grok.ViewletManager):
    grok.context(interface.Interface)
    grok.layer(ISiguvTheme)
Exemplo n.º 14
0
class GlobalMenu(uvc.menus.components.MenuRenderer):
    grok.context(interface.Interface)
    grok.layer(ISiguvTheme)

    bound_menus = ("globalmenu",)
Exemplo n.º 15
0
 def meth(self):
     """We don't allow calling `grok.context` from anything else
     than a module or a class"""
     grok.context(Cave)
Exemplo n.º 16
0
class Inspect(GAIAView):
    """Basic object browser.
    """

    grok.context(Interface)
    grok.name(u'inspect.html')
    grok.require('grok.ManageApplications')

    _metadata = None

    def update(self, show_private=False, *args, **kw):
        obj = self.context
        if isinstance(self.context, ZopeObjectInfo):
            # When the docgrok-object traverser delivers content, then
            # we get a wrapped context: the meant object is wrapped
            # into a ZopeObjectInfo.
            obj = self.context.obj

        self.ob_info = ZopeObjectInfo(obj)
        ob_info = self.ob_info
        self.show_private = show_private
        root_url = self.root_url()
        parent = ob_info.getParent()
        parent = {
            'class_link': parent and getPathLinksForObject(parent) or '',
            'obj_link': getItemLink('', getParentURL(self.url(''))),
            'obj': parent
        }
        bases = [getPathLinksForClass(x) for x in ob_info.getBases()]
        bases.sort()

        ifaces = [
            getPathLinksForClass(x) for x in ob_info.getProvidedInterfaces()
        ]
        ifaces.sort()

        methods = [
            x for x in list(ob_info.getMethods())
            if self.show_private or not x['name'].startswith('_')
        ]
        for method in methods:
            if method['interface']:
                method['interface'] = getPathLinksForDottedName(
                    method['interface'], root_url)
            if method['doc']:
                method['doc'] = renderText(method['doc'],
                                           getattr(obj, '__module__', None))

        attrs = [
            x for x in list(ob_info.getAttributes())
            if self.show_private or not x['name'].startswith('_')
        ]
        for attr in attrs:
            if '.' in str(attr['type']):
                attr['type'] = getPathLinksForClass(attr['type'], root_url)
            else:
                attr['type'] = attrEscape(str(attr['type']))
            if attr['interface']:
                attr['interface'] = getPathLinksForDottedName(
                    attr['interface'], root_url)
            attr['obj'] = getattr(obj, attr['name'], None)
            attr['docgrok_link'] = getItemLink(attr['name'], self.url(''))
        attrs.sort(lambda x, y: x['name'] > y['name'])

        seqitems = ob_info.getSequenceItems() or []
        for item in seqitems:
            if '.' in str(item['value_type']):
                item['value_type'] = getPathLinksForClass(
                    item['value_type'], root_url)
            else:
                item['value_type'] = attrEscape(str(item['value_type']))
            item['obj'] = obj[item['index']]
            item['docgrok_link'] = getItemLink(item['index'], self.url(''))
        seqitems.sort()

        mapitems = [
            x for x in ob_info.getMappingItems()
            if self.show_private or not x['key'].startswith('_')
        ]
        for item in mapitems:
            if '.' in str(item['value_type']):
                item['value_type'] = getPathLinksForClass(
                    item['value_type'], root_url)
            else:
                item['value_type'] = attrEscape(str(item['value_type']))
            item['obj'] = obj[item['key']]
            item['docgrok_link'] = getItemLink(item['key'], self.url(''))
        mapitems.sort(lambda x, y: x['key'] > y['key'])

        annotations = [
            x for x in ob_info.getAnnotationsInfo()
            if self.show_private or not x['key'].startswith('_')
        ]
        for item in annotations:
            if '.' in str(item['value_type']):
                item['value_type'] = getPathLinksForClass(
                    item['value_type'], root_url)
            else:
                item['value_type'] = attrEscape(str(item['value_type']))
            item['docgrok_link'] = getItemLink(item['key'], self.url(''))
        annotations.sort(lambda x, y: x['key'] > y['key'])

        self.info = {
            'name':
            ob_info.getId() or u'<unnamed object>',
            'type':
            getPathLinksForClass(
                (getattr(obj, '__class__', None) or type(obj)), root_url),
            'obj_link':
            getPathLinksForObject(obj, root_url),
            'moduleinfo':
            ob_info.getmoduleinfo(),
            'modulename':
            ob_info.getmodulename(),
            'ismodule':
            ob_info.ismodule(),
            'isclass':
            ob_info.isclass(),
            'ismethod':
            ob_info.ismethod(),
            'isfunction':
            ob_info.isfunction(),
            'iscode':
            ob_info.iscode(),
            'isbuiltin':
            ob_info.isbuiltin(),
            'isroutine':
            ob_info.isroutine(),
            'issequence':
            ob_info.isSequence(),
            'ismapping':
            ob_info.isMapping(),
            'isannotatable':
            ob_info.isAnnotatable(),
            'doc':
            renderText(ob_info.getdoc(), None),
            'comments':
            ob_info.getcomments(),
            'module':
            ob_info.getmodule(),
            'sourcefile':
            ob_info.getsourcefile(),
            'source':
            ob_info.getsource(),
            'parent':
            parent,
            'dotted_path':
            ob_info.getPythonPath(),
            'provided_interfaces':
            ob_info.getDirectlyProvidedInterfaces(),
            'interfaces':
            ifaces,
            'bases':
            bases,
            'attributes':
            attrs,
            'methods':
            methods,
            'sequenceitems':
            seqitems,
            'mappingitems':
            mapitems,
            'annotations':
            annotations
        }
Exemplo n.º 17
0
    def __init__(self, title='', summary='', content='', categories=[]):
        Entry.__init__(self, title, summary, categories)
        self.content = content

class Comment(grok.Model):
    interface.implements(interfaces.IComment, IAttributeAnnotatable)
    comment = u""
    date = datetime.now() 
    author = u""
    
    def __init__(self, comment, author):
        self.comment = comment
        self.author = author
        self.date = datetime.now()

grok.context(RestructuredTextEntry)

class EntryIndex(grok.Viewlet):
    grok.viewletmanager(Main)
    grok.view(Index)
    
    def update(self):
        self.comments=sorted(self.context.values(), key=lambda c:c.date)
    
class Item(grok.View):
    pass

class AddComment(grok.Viewlet):
    grok.context(Entry)
    grok.viewletmanager(Main)
    grok.view(Index)
Exemplo n.º 18
0
class DocGrokView(GAIAView):
    """A base DocGrok view.

    This view is used for all things not covered by other, more
    specialized views.
    """

    grok.context(DocGrok)
    grok.name('index')
    grok.require('grok.ManageApplications')

    def getDoc(self, text=None, heading_only=False):
        """Get the doc string of the module STX formatted."""
        if text is None:
            return None
            if (hasattr(self.context, "apidoc")
                    and hasattr(self.context.apidoc, "getDocString")):
                text = self.context.apidoc.getDocString()
            else:
                return None
        lines = text.strip().split('\n')
        if len(lines) and heading_only:
            # Find first empty line to separate heading from trailing text.
            headlines = []
            for line in lines:
                if line.strip() == "":
                    break
                headlines.append(line)
            lines = headlines
        # Get rid of possible CVS id.
        lines = [line for line in lines if not line.startswith('$Id')]
        return renderText('\n'.join(lines), self.context.getPath())

    def getDocHeading(self, text=None):
        return self.getDoc(text, True)

    def getPathParts(self, path=None):
        """Get parts of a dotted name as url and name parts.
        """
        if path is None:
            path = self.context.path
        if path is None:
            return None
        return getDottedPathDict(path)
        result = []
        part_path = ""
        for part in path.split('.'):
            name = part
            if part_path != "":
                name = "." + part
            part_path += part
            result.append({'name': name, 'url': "/docgrok/%s" % (part_path, )})
            part_path += "/"
        return result

    def getEntries(self, columns=True):
        """Return info objects for all modules and classes in the
        associated apidoc container.

        """
        if (not hasattr(self.context, "apidoc")
                or not hasattr(self.context.apidoc, "items")):
            return None
        entries = []
        for name, obj in self.context.apidoc.items():
            entry = {
                'name': name,
                'obj': obj,
                'path': getPythonPath(removeAllProxies(obj)),
                'url': u'',
                'doc': None,
                'ispackage': False,
                'ismodule': False,
                'isinterface': False,
                'isclass': False,
                'isfunction': False,
                'istextfile': False,
                'iszcmlfile': False,
                'signature': None
            }
            entry['url'] = "%s/%s" % (self.context.path.replace('.',
                                                                '/'), name)
            if hasattr(obj, "getDocString"):
                entry['doc'] = self.getDocHeading(obj.getDocString())
            elif hasattr(obj, "getDoc") and isinstance(removeAllProxies(obj),
                                                       InterfaceClass):
                entry['doc'] = self.getDocHeading(obj.getDoc())
            if isinstance(obj, Class):
                entry['isclass'] = True
            elif isinstance(obj, TextFile):
                entry['istextfile'] = True
            elif isinstance(obj, ZCMLFile):
                entry['iszcmlfile'] = True
            elif isinstance(obj, Function):
                entry['isfunction'] = True
                if hasattr(obj, 'getSignature'):
                    entry['signature'] = obj.getSignature()
            elif (isinstance(obj, Module)
                  and os.path.basename(obj.getFileName())
                  in ['__init.py__', '__init__.pyc', '__init__.pyo']):
                entry['ispackage'] = True
            elif isinstance(obj, Module):
                entry['ismodule'] = True
            entries.append(entry)

        entries.sort(lambda x, y: cmp(x['name'], y['name']))
        return entries

    def update(self):
        self.docgrok_root = self.context._traversal_root
        self.app_root = self.docgrok_root.__parent__
        pass
Exemplo n.º 19
0
        self.name = name


class Special(grok.Model):
    pass


class SpecialIndex(grok.View):
    grok.context(Special)
    grok.name("index")

    def render(self):
        return "special view"


grok.context(Mammoth)


class Index(grok.View):
    pass


index = grok.PageTemplate(
    """\
<html>
<body>
<h1>Hello, <span tal:replace="context/name/title" />!</h1>
</body>
</html>
"""
)
Exemplo n.º 20
0
class DocGrokPackageView(DocGrokView):
    """A view for packages handled by DocGrok."""

    grok.context(DocGrokPackage)
    grok.name('index')
Exemplo n.º 21
0
class PageHeader(grok.ContentProvider):
    grok.context(interface.Interface)
    grok.layer(ISiguvTheme)
    grok.template("header")
Exemplo n.º 22
0
class DocGrokModuleView(DocGrokView):
    """A view for modules handled by DocGrok."""

    grok.context(DocGrokModule)
    grok.name('index')
Exemplo n.º 23
0
class FireView(grok.View):
    grok.context(Interface)
    grok.template('caveview')
Exemplo n.º 24
0
class DocGrokInterfaceView(DocGrokClassView):

    grok.context(DocGrokInterface)
    grok.name('index')
Exemplo n.º 25
0
class TRexBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Pot)

    def render(self):
        return "T-Rex Bone"
Exemplo n.º 26
0
class DocGrokGrokApplicationView(DocGrokClassView):

    grok.context(DocGrokGrokApplication)
    grok.name('index')
Exemplo n.º 27
0
class ManBone(grok.Viewlet):
    grok.viewletmanager(Pot)
    grok.context(CaveMan)

    def render(self):
        return "Man Bone"
Exemplo n.º 28
0
class FormMacros(grok.View):
    grok.context(Interface)
    template = ChameleonPageTemplateFile('templates/formtemplate.cpt')
Exemplo n.º 29
0
class Edit(grok.EditForm):
    grok.context(Mammoth)
Exemplo n.º 30
0
class FieldMacros(grok.View):
    grok.context(Interface)
    template = ChameleonPageTemplateFile('templates/fieldtemplates.cpt')
            graph_xml = form.request.form['data']

            try:
                graph = SetobjectGraph(form.request, graph_xml)
                graph.save()
                jsonresponse['result'] = 'OK'
            except SetobjectGraphException, ex:
                jsonresponse['error'] = {'title': 'Save failed',
                                          'message': ex.reason,
                                          'data_node_id': ex.setobjectid}
            form.jsonresponse = jsonresponse
            
    
    grok.name('index') 
    grok.context(IGenericSet)
    grok.title(_(u"Edit data"))
    grok.require('dolmen.content.View')

    actions = Actions(SaveAction('Save'),)

    def __call__(self):
        if self.request.headers.get('X-Requested-With') == 'XMLHttpRequest':
            self.updateActions()
            self.response.setHeader('Content-Type', 'application/json')
            return json.dumps(self.jsonresponse)
        else:
            return super(EditData, self).__call__() 

    @property
    def prefix(self):
Exemplo n.º 32
0
class AccidentII(uvcsite.Step):
    grok.context(IUnfallanzeige)
    grok.view(UnfallanzeigeWizard)
    grok.order(50)
    ignoreContent = False
    label = form_name = u'Informationen zum Unfall Teil II'

    handleApplyOnBack = True

    fields = base.Fields(IUnfallanzeige).select('prstkz', 'unfae1',
                                                'unfaedatum', 'unfaezeit',
                                                'unfwa1', 'unfwax', 'uadbavon',
                                                'uadbabis', 'diavkt', 'diaadv',
                                                'unfeba', 'unfeba1')

    fields['prstkz'].mode = "radio"
    fields['unfae1'].mode = "radio"
    fields['unfwa1'].mode = "radio"
    fields['unfeba'].mode = "radio"

    def update(self):
        super(uvcsite.Step, self).update()
        resources.step5.need()

    def validateStep(self, data, errors):
        if data.get('prstkz') == "nein":
            if data.get('unfae1') == NO_VALUEM:
                errors.append(
                    Error(
                        'Bitte machen Sie Angaben in diesem Feld.',
                        identifier='form.accidentii.field.unfae1',
                    ))
            else:
                if data.get('unfae1') == "ja, sofort":
                    if data.get('unfwa1') == NO_VALUEM:
                        errors.append(
                            Error('Bitte machen Sie Angaben in diesem Feld.',
                                  identifier='form.accidentii.field.unfwa1'))
                    else:
                        if data.get('unfwa1') == "ja":
                            if data.get('unfwax') == NO_VALUE:
                                errors.append(
                                    Error(
                                        'Bitte machen Sie Angaben in diesem Feld.',
                                        identifier=
                                        'form.accidentii.field.unfwax'))

                elif data.get('unfae1') == "ja, spaeter am:":
                    if data.get('unfwa1') == NO_VALUEM:
                        errors.append(
                            Error('Bitte machen Sie Angaben in diesem Feld.',
                                  identifier='form.accidentii.field.unfwa1'))
                    if data.get('unfwa1') == "ja":
                        if data.get('unfwax') == NO_VALUE:
                            errors.append(
                                Error(
                                    'Bitte machen Sie Angaben in diesem Feld.',
                                    identifier='form.accidentii.field.unfwax'))
                    if data.get('unfaedatum') == NO_VALUE:
                        errors.append(
                            Error(
                                'Bitte machen Sie Angaben in diesem Feld.',
                                identifier='form.accidentii.field.unfaedatum'))
                    if data.get('unfaezeit') == NO_VALUE:
                        errors.append(
                            Error(
                                'Bitte machen Sie Angaben in diesem Feld.',
                                identifier='form.accidentii.field.unfaezeit'))
        if data.get('unfeba') == "Aerztliche Behandlung bei:":
            if data.get('unfeba1') == NO_VALUE:
                errors.append(
                    Error('Bitte machen Sie Angaben in diesem Feld.',
                          identifier='form.accidentii.field.unfeba1'))
        return errors
Exemplo n.º 33
0
from z3c.batching.batch import Batch
from bioport import BioportMessageFactory as _
from bioport.app import RepositoryView, Batcher, Bioport, get_born_description, get_died_description, get_alive_description
from fuzzy_search import get_search_query
from fuzzy_search import en_to_nl_for_field
#from fuzzy_search import make_description

try:
    from zope.i18n.interfaces import IUserPreferredLanguages  # after python 2.6 upgrade
except ImportError:
    from zope.app.publisher.browser import IUserPreferredLanguages  # before python 2.6 upgrade
from names.common import to_ymd

grok.templatedir('app_templates')
grok.context(Bioport)


class _Personen(RepositoryView):
    def get_persons(self, **args):
        """get Persons - with restrictions given by request"""
        qry = {}
        #request.form has unicode keys - make strings
        for k in [
            'bioport_id',
            'beginletter',
            'category',
            'geboortejaar_min',
            'geboortejaar_max',
            'geboorteplaats',
            'geslacht',
Exemplo n.º 34
0
import grok
from zope.interface import Interface


class GrokstarAddForm(grok.AddForm):
    pass


class GrokstarEditForm(grok.EditForm):
    pass


grok.context(Interface)
Exemplo n.º 35
0
from oship.openehr.rm.datatypes.text import DvText 
from oship.openehr.rm.demographic import Person, PartyIdentity
from oship.openehr.rm.datatypes.quantity.datetime import DvDate
from oship.openehr.rm.data_structures.item_structure import ItemTree
from oship.openehr.rm.data_structures.item_structure.representation import Element


_ = MessageFactory('oship')


# Begin Blood Pressure Tracker Demo
class BPTrack(grok.Application, grok.Container):
    pass


grok.context(BPTrack)

class Index(grok.View):

    def render(self):
        try:
            self.context['demographics'] = grok.Container() # demographics space
            self.context['clinical'] = grok.Container() # clinical space
        except:
            pass


        self.redirect(self.application_url()+"/bpmain")

# Main view
class BPMain(grok.View):
Exemplo n.º 36
0
class Ellie(grok.View):
    grok.context(Herd)
    grok.name('ellie')

    def render(self):
        return "Hi, it's me, the Ellie view!"
Exemplo n.º 37
0
  True
  >>> isinstance(home, Home)
  True

"""
import grok
from zope import interface


class ICave(interface.Interface):
    pass


class Cave(grok.Model):
    grok.implements(ICave)


class Hole(grok.Model):
    grok.implements(ICave)


grok.context(ICave)


class IHome(interface.Interface):
    pass


class Home(grok.Adapter):
    grok.implements(IHome)
Exemplo n.º 38
0
class MammothIndex(grok.View):
    grok.context(Mammoth)
    grok.name('index')

    def render(self):
        return "Hello " + self.context.name.title()
Exemplo n.º 39
0
# -*- coding: utf-8 -*-

from zope.site.interfaces import IRootFolder
from zope.component import getUtility, getMultiAdapter
from zope.browsermenu.interfaces import IBrowserMenu
import grok
from megrok.menu import Menu
from grokui.base import IGrokUIRealm, GrokUILayer

grok.layer(GrokUILayer)
grok.context(IGrokUIRealm)


class Header(grok.ViewletManager):
    grok.name('grokui_header')


class Footer(grok.ViewletManager):
    grok.name('grokui_footer')


class Messages(grok.ViewletManager):
    grok.name('grokui_messages')


class MainMenu(Menu):
    grok.name('grokui_mainmenu')
    grok.title('Grok user interface panels')


class Index(grok.View):
Exemplo n.º 40
0
class TuskIndex(grok.Indexes):
    grok.context(IPachyderm)
    grok.site(Herd)

    tusks = index.Text()
Exemplo n.º 41
0
import grok
from grokcore import message

from zope import component
from zope.i18n import translate
from zope.interface import Interface
from zope.interface.common.interfaces import IException
from zope.app.security.interfaces import IAuthentication

from raptus.mailcone.settings.interfaces import ILogoLocator

from raptus.mailcone.layout import navigation


grok.templatedir('templates')
grok.context(Interface)



class HeaderManager(grok.ViewletManager):
    grok.name('header')



class ContentBeforeManager(grok.ViewletManager):
    grok.name('content.before')



class ContentManager(grok.ViewletManager):
    grok.name('content')
Exemplo n.º 42
0
from zope.schema import TextLine,Datetime
from zope.interface import Interface
from oship.app import OSHIP
from oship.openehr.rm.datatypes.text import DvText 
from oship.openehr.rm.demographic import Person
from oship.openehr.rm.datatypes.quantity.datetime import DvDate
from oship.openehr.rm.data_structures.item_structure import ItemTree
from oship.openehr.rm.data_structures.item_structure.representation import Element

_ = MessageFactory('oship')


class LabRequest(grok.Application, grok.Container):
    pass

grok.context(LabRequest)

class Index(grok.View):

    def render(self):
        try:
            self.context['demographics'] = grok.Container() # demographics space
            self.context['clinical'] = grok.Container() # clinical space
        except:
            pass


        self.redirect(self.application_url()+"/lrmain")

# Main view
class LRMain(grok.View):