예제 #1
0
 def describeModel(cls):
     "Describe the model, using the modeling extension."
     modeling.initialize()
     modeling.describeClass("http://localhost/afy/class/1.0/Circuit", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Category for circuits, indexed by name."})
     modeling.describeClass("http://localhost/afy/class/1.0/Circuit/Component#bypos", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Category for circuits' components, indexed by 2D-position."})
     modeling.describeRelation("http://localhost/afy/property/1.0/circuit/components", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Collection of components.", modeling.AFYURI_PROP_CATEGORY:"http://localhost/afy/class/1.0/Circuit/Component#bypos"})
     modeling.describeRelation("http://localhost/afy/property/1.0/circuit/components", {modeling.AFYURI_PROP_DOCSTRING:"[sample] A circuit has a collection of components.", modeling.AFYURI_PROP_CARDINALITY:modeling.AFY_CARDINALITY_ONE_TO_MANY}, pClassURI="http://localhost/afy/class/1.0/Circuit")
     modeling.describeRelation("http://localhost/afy/property/1.0/circuit/component/inputs", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Collection of components connected as inputs.", modeling.AFYURI_PROP_CATEGORY:"http://localhost/afy/class/1.0/Circuit/Component#bypos"})
     modeling.describeRelation("http://localhost/afy/property/1.0/circuit/component/inputs", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Collection of components connected as inputs.", modeling.AFYURI_PROP_CARDINALITY:modeling.AFY_CARDINALITY_ONE_TO_MANY}, pClassURI="http://localhost/afy/class/1.0/Circuit/Component#bypos")
     modeling.describeRelation("http://localhost/afy/property/1.0/circuit/component/outputs", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Collection of components connected as outputs.", modeling.AFYURI_PROP_CATEGORY:"http://localhost/afy/class/1.0/Circuit/Component#bypos"})
     modeling.describeRelation("http://localhost/afy/property/1.0/circuit/component/outputs", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Collection of components connected as outputs.", modeling.AFYURI_PROP_CARDINALITY:modeling.AFY_CARDINALITY_ONE_TO_MANY}, pClassURI="http://localhost/afy/class/1.0/Circuit/Component#bypos")
     modeling.describeAttribute("http://localhost/afy/property/1.0/circuit/name", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Circuit's name."}, pClassURI="http://localhost/afy/class/1.0/Circuit")
     modeling.describeAttribute("http://localhost/afy/property/1.0/circuit/component/x", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Component's x position."}, pClassURI="http://localhost/afy/class/1.0/Circuit/Component#bypos")
     modeling.describeAttribute("http://localhost/afy/property/1.0/circuit/component/y", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Component's y position."}, pClassURI="http://localhost/afy/class/1.0/Circuit/Component#bypos")
     modeling.describeAttribute("http://localhost/afy/property/1.0/circuit/component/type", {modeling.AFYURI_PROP_DOCSTRING:"[sample] Component's type."}, pClassURI="http://localhost/afy/class/1.0/Circuit/Component#bypos")
예제 #2
0
def _describeModel():
    "Use the modeling extension to describe our schema."
    # Review: Should probably use the singular convention for entities... in all samples... also coherent with "is a" etc... identify if there are inconsistencies...
    modeling.initialize()
    modeling.describeClass("testphotos2_class_photos", {modeling.AFYURI_PROP_DOCSTRING:"General category for photos, by id. Photos typically also contain a 'tags' property."})
    modeling.describeClass("testphotos2_class_tags", {modeling.AFYURI_PROP_DOCSTRING:"General category for unique tags, which logically group photos together into sets, and serve as the basic unit to grant privileges to users and groups."})
    modeling.describeClass("testphotos2_class_groups", {modeling.AFYURI_PROP_DOCSTRING:"Category for groups of users. Groups typically also contain a 'tags' property, representing the sets of photos to which a group was granted access."})
    modeling.describeClass("testphotos2_class_users", {modeling.AFYURI_PROP_DOCSTRING:"Category for users (guests of an instance of the photo system). Users typically also contain a 'tags' property, representing the sets of photos to which an individual user was granted access (additionally to the access rights of the group it this user belongs to)."})
    modeling.describeRelation("testphotos2_tags", {modeling.AFYURI_PROP_DOCSTRING:"Collection of tags.", modeling.AFYURI_PROP_CATEGORY:"testphotos2_class_tags"})
    modeling.describeRelation("testphotos2_tags", {modeling.AFYURI_PROP_DOCSTRING:"All photos containing the same tag form a set (album).", modeling.AFYURI_PROP_CARDINALITY:modeling.AFY_CARDINALITY_ONE_TO_MANY}, pClassURI="testphotos2_class_photos")
    modeling.describeRelation("testphotos2_tags", {modeling.AFYURI_PROP_DOCSTRING:"All users of a group are granted permission to view the photos tagged with the tags of their group.", modeling.AFYURI_PROP_CARDINALITY:modeling.AFY_CARDINALITY_ONE_TO_MANY}, pClassURI="testphotos2_class_groups")
    modeling.describeRelation("testphotos2_tags", {modeling.AFYURI_PROP_DOCSTRING:"A user is granted permission to view the photos tagged with its tags.", modeling.AFYURI_PROP_CARDINALITY:modeling.AFY_CARDINALITY_ONE_TO_MANY}, pClassURI="testphotos2_class_users")
    modeling.describeRelation("testphotos2_users", {modeling.AFYURI_PROP_DOCSTRING:"Collection of users.", modeling.AFYURI_PROP_CATEGORY:"testphotos2_class_users"})
    modeling.describeRelation("testphotos2_users", {modeling.AFYURI_PROP_DOCSTRING:"A group is composed of users.", modeling.AFYURI_PROP_CARDINALITY:modeling.AFY_CARDINALITY_ONE_TO_MANY}, pClassURI="testphotos2_class_groups")
    modeling.describeAttribute("testphotos2_id", {modeling.AFYURI_PROP_DOCSTRING:"The unique id of a photo is built from the sha-1 digest of the pixels (n.b. in this demo, it's just a random guid)."}, pClassURI="testphotos2_class_photos")
    modeling.describeAttribute("testphotos2_id", {modeling.AFYURI_PROP_DOCSTRING:"The unique id of a user is an email id."}, pClassURI="testphotos2_class_users")
    modeling.describeAttribute("testphotos2_id", {modeling.AFYURI_PROP_DOCSTRING:"The unique id of a group is the name of the group."}, pClassURI="testphotos2_class_groups")
    modeling.describeAttribute("testphotos2_tag", {modeling.AFYURI_PROP_DOCSTRING:"A tag is a text string representative of a collection of photos."}, pClassURI="testphotos2_class_tags")
    modeling.describeAttribute("testphotos2_pw", {modeling.AFYURI_PROP_DOCSTRING:"pw is a guest user's individual password, securing his access to the database of photos."}, pClassURI="testphotos2_class_users")
    modeling.describeAttribute("testphotos2_date", {modeling.AFYURI_PROP_DOCSTRING:"The date the picture was taken. Used to order the presentation of photos in a tag, and to provide date-driven views on photos accessible to a user."}, pClassURI="testphotos2_class_photos")
    modeling.describeAttribute("testphotos2_time", {modeling.AFYURI_PROP_DOCSTRING:"The time of day the picture was taken. Used to order the presentation of photos in a tag."}, pClassURI="testphotos2_class_photos")
    modeling.describeAttribute("testphotos2_path", {modeling.AFYURI_PROP_DOCSTRING:"The physical file path of the photo."}, pClassURI="testphotos2_class_photos")
    modeling.describeAttribute("testphotos2_name", {modeling.AFYURI_PROP_DOCSTRING:"The file name of the photo."}, pClassURI="testphotos2_class_photos")
예제 #3
0
파일: cnp.py 프로젝트: affinitydb/python
    #lCnp = CartAndPole(lMainCanvas, lambda:EvaluationPy())
    lCnp = CartAndPole(lMainCanvas, lambda:EvaluationPathSQL(lAffinity))

    # Implement menu handlers.
    def onMenuRestart():
        lCnp.restart()

    # Configure the main menu.
    lMenuBar = Menu(lRootUI)
    lMainMenu = Menu(lMenuBar, tearoff=0)
    lMainMenu.add_command(label="Restart", command=onMenuRestart)
    lMainMenu.add_command(label="Exit", command=lRootUI.quit)
    lMenuBar.add_cascade(label="Options", menu=lMainMenu)
    lRootUI.config(menu=lMenuBar)

    # Configure basic mouse selection.
    def softCtrlSelectComponent(event):
        return
    def softSelectComponent(event):
        return
    lMainCanvas.bind("<Button-1>", softSelectComponent)
    lMainCanvas.bind("<Control-Button-1>", softCtrlSelectComponent)
    lMainCanvas.bind("<Shift-Button-1>", softCtrlSelectComponent)

    # Run.
    modeling.initialize()
    lCnp.onTimer()
    lRootUI.mainloop()
    lAffinity.close()
    print ("cnp exited normally.")