def end_with_layout(): """\ End a form started with ``start_with_layout()`` >>> end_with_layout() literal(u'</table></form>') """ return literal("</table>")+end_form()
def form_end(*k, **p): """\ End a form started with ``form_start()`` >>> form_end() literal(u'</form></table>') """ return HTML.tag("/table", _closed=False) + end_form(*k, **p)
def form_end(*k, **p): """\ End a form started with ``form_start()`` >>> form_end() literal(u'</form></table>') """ return literal("</table>")+end_form(*k, **p)
def end(self): """ Closes the form, i.e. outputs </form>. """ return tags.end_form()
def secure_link(href, value='Submit', value_formatted=None, title=None, method='post', form_data=None, link_data=None, link_class='', parent_id=None, force_profile=False): #def secure_link(href, value='Submit', value_formatted=None, css_class='', title=None, rel=None, confirm_text=None, method='POST', json_form_complete_actions='', modal_params=None, data={}): """ Create two things: - A visible HTML form which POSTs some data along with an auth token - An invisible pretty-looking plain-text link which calls form.submit() Then use javascript to hide the form and show the pretty link @param href - can be supplied as a string or a tuple in the format (args, kwargs), this tuple will then be used to automatically create href_json @param href_json - an optional JSON url to post to can be provided, this will then activate an AJAX call, this is normally set automatically by providing a tuple for href (see above) @param javascript_json_complete_actions - a string of javascript that is activated on a successful AJAX call. Normally used to refresh parts of the page that have been updated from the successful AJAX call. """ if not value_formatted: value_formatted = value else: value_formatted = literal(value_formatted) if not form_data: form_data = {} if not link_data: link_data = {} # Setup Get string href ---- # the href could be passed a a tuple of (args,kwargs) for form() to create a JSON version to submit to # we need a text compatable href reguardless href_original = copy.deepcopy(href) if isinstance(href, tuple): args = href[0] kwargs = href[1] form_href = url(*args, **kwargs) kwargs['format'] = 'json' data_json = url(*args, **kwargs) #form_data = dict([(key.replace('_', '-' if '_' in key else key, form_data[key])) for key in form_data.keys()]) # GregM: Work out what to do is json_complete has not been defined manually, this could and will fail on odd cercumstances if not form_data.get('json_complete'): args = list(args) args[0] = action_single_map.get(args[0], args[0]) if kwargs.get('format'): del kwargs['format'] kwargs['action'] = 'show' action1 = ['remove'] if method == 'DELETE' or method == 'delete' else ['update'] action2 = ['update', [url(*args, **kwargs)], None, None] if parent_id: kwargs['id'] = parent_id action2[1].append(url(*args, **kwargs)) if args[0] == 'member' or force_profile: action2[1].append('/profile') form_data['json_complete'] = json.dumps([action1, action2]).replace('"',"'") # Do magic to convert all form & link _data to kwargs form_data = dict([ ('data-%s' % k.replace('_','-'), v if isinstance(v, basestring) else json.dumps(v)) for (k,v) in form_data.items() ]) link_data = dict([ ('data-%s' % k.replace('_','-'), v if isinstance(v, basestring) else json.dumps(v)) for (k,v) in link_data.items() ]) # Keep track of number of secure links created so they can all have unique hash's #hhash = hashlib.md5(uniqueish_id(href, value, vals)).hexdigest()[0:6] # GregM: Semi-unique ids required for selenium, these will be unique to every action (multiple of same action can exist) # hhash = re.sub(funky_chars, '_', re.sub(link_matcher, '', href)) + '_' + method # Create Form -------- #AllanC: without the name attribute here the AJAX/JSON does not function, WTF! took me ages to track down :( NOTE: if the name="submit" jQuery wont submit! a known problem!? hf = form(href_original, method=method, class_='hide_if_js', **form_data) + \ HTML.input(type="submit", value=value, name=value) + \ end_form() #, hl = HTML.a( value_formatted , href = '#', class_ = link_class + ' hide_if_nojs link_secure', # GregM: secure_show means js will show element and remove class (to stop dup processing of same element) title = title, **link_data ) return HTML.span(hf+hl, class_="secure_link") #+json_submit_script
def end(self): """ Closes the form, i.e. outputs </form>. """ return self.hidden_tag() + tags.end_form()
def end(self): return tags.end_form()