[Grok-dev] bypass UI adding application to grok AND multiple applications under /src howto?

Christian Schmidt grok-list at creativenet.de
Mon Jan 16 16:55:13 UTC 2012


regarding the generations issue, Christian brought me to the right way, 
so I was able so solve this too.

I made the following:

cd src/example/
mkdir generations
cd generations
touch __init__.py
touch util.py
touch install.py
touch evolve1.py

util.py:

import grok
from zope.generations.generations import SchemaManager
from zope.generations.interfaces import ISchemaManager


schemaManager = SchemaManager(
         minimum_generation=1,
         generation=1,
         package_name='example.generations'
         )


grok.global_utility(
         schemaManager,
         provides=ISchemaManager,
         name="example",
         direct=True
         )

install.py:

from example.app import Example
from zope.generations.utility import getRootFolder

def evolve(context):
         root = getRootFolder(context)
         root['example'] = Example()      #<- root['example']  is the 
name of your Application displayed by the UI
         print "CREATED App example"


evolve1.py:

from zope.generations.utility import getRootFolder

def evolve(context):
         root = getRootFolder(context)
         app = root['example']

cd ../

configure.zcml (example/src/example/configure.zcml):

<include package="zope.generations" file="subscriber.zcml"/> #<-  NOT 
file="subscriptions.zcml"

cd ../../
add zope.generations to global setup.py:

example/setup.py:
  install_requires= [ ...
                         'zope.generations',

rerun buildout.

running your application will display "CREATED App example" on startup. 
UI displays example as installed application.

Cheers Christian Schmidt






Am 01/16/2012 14:51, schrieb Matt Rutherford:
> As he pointed out to me above, you need to add your new package 
> 'mynewapp' to the top-level setup.py's install_requires list, buildout 
> again and then it will appear as another option in the admin gui.
>
> On 16 January 2012 13:33, Christian Schmidt <grok-list at creativenet.de 
> <mailto:grok-list at creativenet.de>> wrote:
>
>     Hello Christian,
>
>     first thank you for your reply. I followed your advice but like
>     Matt i have still the same problem for trying to add a second
>     application. Grok answers with the default app. Here is exactly
>     what I did:
>
>     grokproject example
>     cd example/src
>     ../bin/paster create -t basic_package mynewapp
>
>     This create a new package base stucture unter
>     example/src/mynewapp/mynewapp/
>
>      __init__py.
>
>     I added there
>
>     app.py
>     app_templates/
>     static
>     configure.zcml
>
>     src/mynewapp/mynewapp/app.py:
>
>     import grok
>
>     #from example import resource
>
>     class Mynewapp(grok.Application, grok.Container):
>       pass
>
>     class Index(grok.View):
>       def render(self):
>     <---->return "this is mynewapp"
>
>     src/mynewapp/mynewapp/configure.zcml:
>
>
>     <configure xmlns="http://namespaces.zope.org/zope"
>               xmlns:grok="http://namespaces.zope.org/grok">
>     <include package="grok" />
>     <includeDependencies package="." />
>
>     <grok:grok package="." />
>     </configure>
>
>     finally i changed the example/buildout.cfg:
>
>     develop = . src/mynewapp
>
>     [app]
>     eggs =
>     added ->        mynewapp
>
>     AND
>
>     site.zcml =<include package="mynewapp"/>
>
>     then ran bin/buildout
>
>     returned:
>
>     Develop: '/usr/home/chris_dev/example/.'
>     Develop: '/usr/home/chris_dev/example/src/mynewapp'
>
>     started the application and added mynewapp under UI:
>     -> mynewapp (example.app.Example)
>
>     http://127.0.0.1:8080/mynewapp/index returned the default application.
>
>      -> example/app_templates/index.pt <http://index.pt> (index.pt
>     <http://index.pt>)
>
>     If i change src/mynewapp/mynewapp/app.py: to -> Index1(grok.View):
>     the page was not found.
>
>     I would be thankful, if you have further ideas or solutions.
>
>     Kind regard
>
>     _______________________________________________
>     Grok-dev mailing list
>     Grok-dev at zope.org <mailto:Grok-dev at zope.org>
>     https://mail.zope.org/mailman/listinfo/grok-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/grok-dev/attachments/20120116/5c28578a/attachment.html>


More information about the Grok-dev mailing list