• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
PyPedia
 

PyPedia

on

  • 1,421 views

PyPedia: The free programming environment that anyone can edit! PyPedia is a collaborative programming web environment. Each article in this wiki is a function or class or any other piece of Python ...

PyPedia: The free programming environment that anyone can edit! PyPedia is a collaborative programming web environment. Each article in this wiki is a function or class or any other piece of Python code. No need to import anything. Just call the function or instantiate the class that belongs to any other article.

Statistics

Views

Total Views
1,421
Views on SlideShare
1,234
Embed Views
187

Actions

Likes
1
Downloads
3
Comments
1

27 Embeds 187

http://kevin-gattaca.blogspot.com 61
http://kevin-gattaca.blogspot.fr 30
http://kevin-gattaca.blogspot.nl 12
http://kevin-gattaca.blogspot.co.uk 10
http://kevin-gattaca.blogspot.ch 9
http://kevin-gattaca.blogspot.de 9
http://kevin-gattaca.blogspot.ca 8
http://kevin-gattaca.blogspot.co.at 6
http://kevin-gattaca.blogspot.se 6
http://feeds.feedburner.com 5
http://kevin-gattaca.blogspot.co.nz 4
http://kevin-gattaca.blogspot.it 4
http://kevin-gattaca.blogspot.jp 3
http://kevin-gattaca.blogspot.cz 3
http://kevin-gattaca.blogspot.com.au 2
http://kevin-gattaca.blogspot.com.br 2
http://kevin-gattaca.blogspot.com.ar 2
http://kevin-gattaca.blogspot.sg 2
http://kevin-gattaca.blogspot.com.es 1
http://kevin-gattaca.blogspot.tw 1
http://kevin-gattaca.blogspot.hu 1
http://kevin-gattaca.blogspot.in 1
http://kevin-gattaca.blogspot.dk 1
http://kevin-gattaca.blogspot.fi 1
http://kevin-gattaca.blogspot.kr 1
http://feedproxy.google.com 1
http://kevin-gattaca.blogspot.pt 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Nice! Blogged it http://kevin-gattaca.blogspot.com
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    PyPedia PyPedia Presentation Transcript

    • PyPediaThe free programming environment that anyone can edit!
    • From:http://wiki.python.org/moin/SandboxedPythonHmm.. nice idea.Fortunately, there is a Sandboxed Python: googleappengine..and an advanced, highly extendable wiki engine: MediawikiThe combination of all these is… PyPediaThis presentation takes a tour to the core functionality of www.pypedia.com
    • Let’s say you have a method in python:
    • • Sign in www.pypedia.com . Suppose that your username is “JohnDoe”. (In the rest of this presentation replace “JohnDoe” with your username)• Create an article with title: Foo_user_JohnDoe• Save the article with the prefilled text unchanged.
    • The articleshouldlook like this
    • • Edit the “code” section and add the code of the method.• Tip: Click three times in the code text area for code friendly formatting.
    • • Save the edit.• Done! You have a script of your own published in PyPedia.• In the article, press the “Execute on browser” button ( )• The function’s output and returned value appear in an area under the button:
    • • Let’s add some parameters• Edit the code:
    • • Then edit the parameters section:• This is what you see:• Inside the <inputs> tags add the text:<param name="arg_1" type="data" value="default_input" label="Enter value for argument 1:"/><param name="arg_2" type="eval" value=”4" label="Enter value for argument 2:"/>
    • • What are all these?? Ignore this part Automatically generated (Edits here will be removed) Add this part Text to display in the form • If type=“data” then the input is treated as stringThe name of the argument • If type=“eval” then the input is treated as Default values python expression (i.e. [3,4,5])
    • • Click save. The parameters section of the article should look like this:• Fill the parameters and press the “Execute on browser” button. This should appear: Play with the arguments. A complete online script has been created!
    • Cool, but I want to call the function from my localcomputer..• Install the PyPedia python library:git clone git://github.com/kantale/pypedia.git• Load the function in python:>>> import pypedia>>> from pypedia import Foo_user_JohnDoe>>> print foo_user_JohnDoe(“test”, [1,2,3]) function foo Arguments: test [1,2,3] 42>>>• You can call the method of any user and your method can be called by anyone
    • Some tips of the python library:• pypedia.before_timestamp = “20120416000000” – Import the most recent revision of functions and classes that are older than 16/4/2012 (something like method permalinks..)• pypedia.enable_cache = True – Suppress method download if method already exists• pypedia.debug = True – For debug info• pypedia.warnings = False – Suppress warnings
    • You can call the function from the PyPedia front page:
    • Now let’s make another article:• Create the article: Goo_user_JohnDoe• Edit the code section:
    • • Save and press the button “Execute on browser”• A method can call any other method without importing.• All PyPedia articles belong to the same namespace (as with any wiki).• Same behavior exists for classes.
    • • In the Goo_user_JohnDoe article press the “Download code” button.• The file Goo_user_JohnDoe.py is downloaded.• Open this file with a text editor:• It contains all the code required for executing the method (including the user parameters).• Executing locally the method is as simple as:#> python Goo_user_JohnDoe.py
    • • In the Foo_user_JohnDoe article edit the section “Unit tests”:
    • • Now edit the code of the method (edit the code section) so that it will not return 42, but something else. Upon saving, this pops up:• With unitests you can guarantee a certain behavior of your methods.
    • • As with any wiki, in PyPedia a method can have more than one name:• Create the page: Hoo_user_JohnDoe• Replace all the prefilled text with: #REDIRECT [[Foo_user_JohnDoe]]• Save the page• In the front page run:Hoo_user_JohnDoe("test", [1,2,3])• The result is exactly the same as running the function: Foo_user_JohnDoe
    • Executing a method in a remote computer:• Edit your user page and add an “ssh” section: ==ssh== host=www.example.com username=JohnDoe path=/home/JohnDoe/runPyPedia• Substitute the above values with real ones for a computer that you have remote access (the username doesn’t have to be the same as your PyPedia username).
    • • Save the page.• This content is NOT shown to anyone and there isn’t anyway to retrieve it (to change just make another “ssh” section).• Login and cd to the path that you declared of your remote computer.• Install there: – The PyPedia python library:git clone git://github.com/kantale/pypedia.git – The utility ssh_wpl_client:wgethttps://raw.github.com/kantale/PyPedia_server/master/utils/ssh_wpl_client.py
    • • On the article Foo_user_JohnDoe press the “Execute on remote computer” button.• Enter the password of your remote computer and press GO!• A new tab opens with the following content:
    • PyPedia’s REST api:• http://www.pypedia.com/index.php?get_code=G oo_user_JohnDoe(1,2) – Fetch the constraint-free version necessary to run the command Goo_user_JohnDoe(1,2) – Use wget or curl to save the content in a file• http://www.pypedia.com/index.php?b_timestam p=20120418000000&get_code=Goo_user_JohnD oe(1,2) – Fetch the most recent revision of the constraint-free version of the code as it was before 18/4/2012• By sharing these links we can archive and reproduce our analysis.
    • Who can edit my article?• By default only you (and the admins) can edit any part of the article.• Edit the Permissions subsections and add any users (coma separated) that you want to allow editing.• Special user names: – SIGNED: Any signed user can edit this section – ALL: Any user can edit this section
    • • On the top of each article there is a button:• With this you can create a personalized version of the article that only you can edit.• For example if you fork the article: Foo_user_Someonethen the article Foo_user_JohnDoewill be created with the same content but with different user privileges.• This is similar to the Github’s “fork” feature.
    • What is the “Development Code” section ?• ANY user (yes any) can edit this section. The code is not parsed, not downloaded and not run at all.• Users (that are not allowed to edit) should use this section to make suggestions for code corrections.• Alternatively they can use the Talk pages for comments regarding any part of the article.
    • • The Documentation, Return and See also subsections allow any kind of content.• Use wiki text formatting in these sections to document your method and help other people to use it.
    • • All content is under the Simplified BSD License• Articles that are well written and documented with thorough unitests and parameters may be copied to the main namespace by the admins• I.e. if the method Foo_user_JohnDoe is good enough, the admins can create the article Foo with the same content• Only the admins can edit the main namespace
    • How safe are the contents of PyPedia ??• Run “User” methods only if you trust the code or the user (or if you are running in a sandbox).• The admins can delete methods with misleading and/or malicious content.• Methods in the main namespace should be considered safe.• As with any open content no guarantee is given for the security or efficiency of the code.
    • Thanks for reading!• Contact: admin@pypedia.com• Join us in google groups: http://groups.google.com/group/pypedia• Twitter: @PyPedia• PyPedia’s source code: – Mediawiki extension: https://github.com/kantale/PyPedia_server – Python library: https://github.com/kantale/pypedia