archive-com.com » COM » T » TELECOMMUNITY.COM

Total: 388

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • PeakWebHowTo - The PEAK Developers' Center
    self config processXML web TEMPLATE SCHEMA self slides data quote self TEMPLATE pwt document web TemplateDocument self slides def main root config makeRoot server WSGIServer root socketURL tcp localhost 8917 server cgiCommand SlideShow server server run if name main main In real applications templates usually come from disk files in this example we put template text into the program body to simplify example setup Insertion of dynamic content is controlled by magic element attributes in namespaces this content and with this means we want to do something with the element holding the attribute content specifies actions on the contents of the element and with provides parameters for the element rendering Namespaces this and content out of the box allow following attribute names is asserts that contents are known under the name set by attribute value E g li this is listItem content replace title sets listItem template for list renderer see below replace contents whole element for this or element contents for contents is replaced by result of path traversal attribute value is path xml contents are replaced by result of path traversal without escaping XML markup list render a sequence of values This DOMlet accepts parameters listItem header emptyList and footer listitem is rendered for each element of the list emptyList is rendered when there are no elements in the list and header and footer are inserted at start and end of the list respectively uses render child elements with target data or skip element altogether Attribute value is traversal expression specifying the starting point for path traversals in child elements unless contents are rendered only if target data is not available expects an assertion as to the type or protocol of the thing currently being handled Attribute value is protocol import specifier DOMlet value will be adapted to that protocol at the time of rendering Names of attributes in namespace with are names of parameters for operating DOMlet In the above example content type is a parameter of HTML page renderer Adding your own DOMlets You may develop custom content handlers and register them for use in this and content attributes of template elements In the following example we display the tree image when our slide refers to the larch python class SlideShow web Location binding metadata index html security Anybody slides security Anybody slides binding Make Slides TEMPLATE html this is page with content type text html body this uses slides next h1 content replace p this when larch img src http www ank sia com alex larch jpg p body html index html binding Make lambda self config processXML web TEMPLATE SCHEMA self slides data quote self TEMPLATE pwt document web TemplateDocument self slides class WhenLarch peak web templates Element Render only if traversal result contains word Larch enable dynamic contents staticText None def renderFor self data state if self dataSpec td ts self traverse data state if Larch in td current state write self openTag for child in self optimizedChildren child renderFor data state state

    Original URL path: http://peak.telecommunity.com/DevCenter/PeakWebHowTo (2016-04-24)
    Open archived version from archive


  • WritingInterfaces - The PEAK Developers' Center
    behavior oriented and you should question any interface whose name is a noun that doesn t imply behavior e g IAttachable IConfigurable IResolver IObjectFactory An interface usually is about a single clear responsibility Generally speaking you don t want to lump multiple responsibilities into an interface because you might want to perform them using different objects at some point and at that point you would already have a bunch of code expecting those responsibilities in one object Interface inheritance usually comes into play when some clients of the interface need additional capabilities but not all suppliers of the interface will be able to provide those additional capabilities Or sometimes there s a component that for convenience reasons will aggregate a variety of features and you use inheritance to assemble an interface from the various sub interfaces Regarding behavior and interfaces with interfaces being a vital part of code as opposed a docstring container From http www eby sarna com pipermail peak 2004 September 001783 html To some extent this view of interfaces is influenced by PyProtocols PEP 246 Without object adaptation interfaces aren t quite as useful But with adaptation the best way to design a collaboration of objects is

    Original URL path: http://peak.telecommunity.com/DevCenter/WritingInterfaces (2016-04-24)
    Open archived version from archive

  • WritingComponents - The PEAK Developers' Center
    cpanels ControlPanelType2 offerAs IControlPanel radiativeElement binding Make Radartronic263 offerAs IRadiative class ControlPanelType2 binding Component powerSupply binding Obtain IPowerSupply button0 binding Make Button 2 Questions and Answers Regarding building components and ways to think about binding Obtain and binding Make From http www eby sarna com pipermail peak 2004 September 001778 html Q When would I choose Make over Obtain and vice versa A Obtain can access the binding system the configuration system or the naming system depending on what argument you give As a general rule accessing the binding or configuration systems will cause Obtain to provide existing components and accessing the naming system will produce a new component But there are exceptions especially since you can create your own binding IComponentKey implementations for use with Obtain and they can do whatever you want But the general idea of Obtain is I know this is out there somewhere go get it for me Make on the other hand generally means make me one of these But again you can create your own binding IRecipe implementations that do whatever you want so there are exceptions to that rule as well You can also apply Make to any function or lambda so the possibilities of what it can do are endless In a way Obtain is a specialization of Make that just looks things up instead of making them From a question to the mail list about adding component children at runtime and related configurations From http www eby sarna com pipermail peak 2004 September 001746 html Q I would like to add Component children to a component at runtime as well as advertise those components to other children under certain Interfaces or configuration paths How do I do this A Are the interfaces different each time or is there a set

    Original URL path: http://peak.telecommunity.com/DevCenter/WritingComponents (2016-04-24)
    Open archived version from archive

  • WritingAdaptors - The PEAK Developers' Center
    object or create a wrapper to adapt it From a user example class IEdible Interface Implements an edible behaviour on objects def init a number of attributes that should be enabled in child def PreObj self cmd returns a cmd string class Food advise instancesProvide IEdible def init self pNames self id 12 def PreObj self cmd print hurray adapt IEdible Food Food is a class It does not provide

    Original URL path: http://peak.telecommunity.com/DevCenter/WritingAdaptors (2016-04-24)
    Open archived version from archive

  • AddingPsycopgSupport - The PEAK Developers' Center
    adding a class to handle Pyscopg URLs adding a class to handle the database connection adding a psycopg URL scheme to PEAK s configuration Luckily we can re use the existing Postgres classes to do most of the work Put the following code into mymodule py 1 from peak storage SQL import GenericSQL URL PGSQLConnection 2 3 class PsycopgURL GenericSQL URL 4 supportedSchemes psycopg 5 defaultFactory mymodule PsycopgConnection 6 7 class PsycopgConnection PGSQLConnection 8 DRIVER psycopg 9 10 supportedTypes 11 NUMBER LONGINTEGER INTEGER FLOAT STRING BOOLEAN 12 DATETIME TIME DATE INTERVAL BINARY ROWID 13 This takes care of the URL and Connection classes Now for the URL scheme Put the following in a file called my peak ini peak naming schemes psycopg mymodule PsycopgURL Now you can test it using PEAK s Namespace Navigator like so env PEAK CONFIG my peak ini PYTHONPATH peak n2 psycopg user pass host db Change user pass host and db to appropriate values and you should get an environment which allows you to run ad hoc SQL statements against your database Where you actually put the classes and configuration information is up to you If you already have a site specific library of Python

    Original URL path: http://peak.telecommunity.com/DevCenter/AddingPsycopgSupport (2016-04-24)
    Open archived version from archive

  • DistributePeakApplications - The PEAK Developers' Center
    0 FIXME check error fread pp len 1 f fp FIXME check error pp len 0 arg pp close the file fclose f fp add command line arguments for ii 1 ii argc ii arg strdup argv ii DEBUG printf ARGS n for ii 0 ii myargc ii printf t s n myargv ii set PYTHONPATH to lib subdir sprintf pythonpath slib here here SetEnvironmentVariableA PYTHONPATH pythonpath enable optimizations SetEnvironmentVariableA PYTHONOPTIMIZE 2 change current directory script names may be relative SetCurrentDirectory here load python DLL and get PY Main entry sprintf pythonpath slib python 02d dll here f cookie pyvers dll LoadLibraryEx pythonpath NULL LOAD WITH ALTERED SEARCH PATH if dll NULL FATALERROR Cannot load s error i n pythonpath GetLastError return 1 Py Main GetProcAddress dll Py Main run rc Py Main myargc myargv FIXME free myargv return rc vim set ts 4 sts 4 sw 4 cino 4 et build exe py source 1 Build python script executable from pyrun exe stub 2 3 Copyright 2003 SIA ANK 4 5 History most recent first 6 02 dec 2003 als created 7 8 9 import os 10 import sys 11 from struct import pack 12 13 STUB os path join os path dirname file pyrun exe 14 MAGIC ANK 014 013 012 011 0 15 16 def run out args 17 f open STUB rb 18 stub f read 19 f close 20 21 f open out wb 22 f write stub 23 len f tell 24 for arg in args 25 f write pack i len arg 26 f write arg 27 f write MAGIC 28 dll version sys version info 0 10 sys version info 1 29 dll version int join map str sys version info 2 30 f write pack iii len len args dll version 31 f close 32 33 if name main 34 run sys argv 1 35 36 vim set sts 4 sw 4 et 5 Listing Application Components As i said above there are no direct references to included components in the main script We have to explicitely list all components for Installer to include and analyse them Also some modules from PEAK and standard lib are not found automatically and need to be named explicitely I did this by making a modulefinder hook for the package in which the main executable module resides This hook has hiddenimports attribute which is a list of additional module import names The list is composed by collecting all modules in the main components package ank BBS Protocol and adding some well known names hooks hook ank BBS py source 1 McMillian Installer hooks for BBS Server application 2 3 Copyright 2003 SIA ANK 4 5 List hidden imports for Installer Analysis BBS Protocols 6 some PEAK modules utf 8 encoding etc 7 8 History most recent first 9 02 dec 2003 als created 10 11 try 12 import os 13 except ImportError 14 import sys 15 os sys modules os 16 from pprint import pprint

    Original URL path: http://peak.telecommunity.com/DevCenter/DistributePeakApplications (2016-04-24)
    Open archived version from archive

  • MiscNotes - The PEAK Developers' Center
    levels need to be addressed ZConfig looks like the way to go for app level end user configuration with peak ini style format for developer metaconfiguration EditText of this page last modified 2002 12 13 17 38 40 FindPage by

    Original URL path: http://peak.telecommunity.com/DevCenter/MiscNotes (2016-04-24)
    Open archived version from archive

  • Glossary - The PEAK Developers' Center
    FrontPage RecentChanges TitleIndex WordIndex SiteNavigation HelpContents Component Constructor Factory Initial Naming Context Interface Protocol EditText of this page last modified 2007 03 25 22 34 17 FindPage by browsing title search text search or an index Or try one of

    Original URL path: http://peak.telecommunity.com/DevCenter/Glossary (2016-04-24)
    Open archived version from archive



  •